Fixed bug where the main thread didn't cleanup properly.