Use pthread_exit(3T) to terminate a thread.
Prototype: void pthread_exit(void *status);
#include <pthread.h> int 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 (blocked). 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 if status is not NULL.