If you just want to stop and/or kill all child threads, you can read the list of thread IDs from /proc/pid/task, and send a signal to them with tgkill().
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.