Sometimes that doesn't matter - maybe you are just trying to get the process to exit without core dumping due to running threads accessing things that are disappearing.
I'm not sure there's any better solution if you are dealing with a library that creates threads and doesn't provide an API to shut them down.
I'm not sure there's any better solution if you are dealing with a library that creates threads and doesn't provide an API to shut them down.