Fixed issue with faulty thread termination.