The solution is so easy that you don't see it:
Each of your threads executes in a loop - most likely. At some point of the loop that is being executed in every iteration place a test like the following:
if (!gContinue)
break;
where gContinue is the global variable of type bool, and which should be true as long as your threads should continue working. Once you set gContinue to false, all your threads will fall out of their loops. And beheind that main loop should be a statement that terminates the thread - usually a simple
return
instruction.