Added thread_exit() function.