made an exit for the loop in the TWS example