control the thread shutdown