Improved exit. Switches out of thread.