Position closing logic
Clicking on the position close button cancels the Take Profit and then creates a market order for the amount needed to close the position. If there are no redeemed orders in the position yet, then the orders will be canceled first, and then the position will be closed.