Fixed ability to close when thread is running