Added destroy-thread function.