One important issue about hidden order

Hi, I am using API and today i realize one important problem. For every trade, I set limit/stop loss order. Sometimes, either any limit/stop loss hits then the trade would be closed, the other hidden order would also be cancelled. However, I also have the “close position” signal, when it is executed, it seems the limit/stoploss is still there. this would cause problems later since it might hit and executed one limit/stoploss when I do not have such position… Is there some way that, when i close the trade, such limit/stoploss just automatically cancels?