Hi Ralph,
In backtesting, it may not be possible in a robust fashion. The reason (I think) is that for an order to be filled, an historical trade ("event") must be encountered, to determine the fill price. There is no guarantee, for a given stock, that there will be trades between the point when you submit the closing order, and the end of the trading day.
For real-money trading with Interactive Brokers, it should be a different situation, since a market will develop if you are willing to unload your positions at a steep enough loss.