fix thread shutdown