Insufficient Funds Error When Closing a Margin Position

If you get the "insufficient funds" error when attempting to close a margin position, cancel all your open orders (even stop orders), and try again. Open orders tie up funds which prevent some other orders from being placed.