Fixed issue with pthread_cancel/exit