thread_exit function updated to make it POSIX compatible