when a thread is blocked and how to close it