Register to leave a thread