Fix shutdown procedure of ThreadManagerImpl and TaskScheduler (it won't stop if interrupt() has been invoked during the thread is running)