Use pthread_exit(3THR) to terminate a thread.
Prototype: void pthread_exit(void *status);
#include <pthread.h> void *status; pthread_exit(status); /* exit with status */
The pthread_exit() function terminates the calling thread. All thread-specific data bindings are released. If the calling thread is not detached, then the thread's ID and the exit status specified by status are retained until the thread is waited for via pthread_join(). Otherwise, status is ignored and the thread's ID can be reclaimed immediately. For information on thread detachment, see Set Detach State.
The calling thread terminates with its exit status set to the contents of status.