More thread management: exit() and wait()