> Ok, so I have an issue with cleaning up threads upon a unexpected exit.
What do you mean by "unexpected exit"? Uncaught exception? SIGTERM? ...
> Using atexit doesn't work because it's called after the daemon threads are
I don't follow. Who is killing the daemon threads?
> It it possible that this will cause the program to hang in any case?
If due to a bug in the cleanup thread it hangs - the program will hang as well.
All the best,