fix the bug of thread's exit