Replaced exit() to pthread_exit()