Don't detach pthreads - instead track them and join to them on shutdown