add pthread_join on exit