I use a variable that the thread can get to through the pointer that you pass to the thread function. The main thread sets m_endAllThreads to true, and the worker thread checks this periodically. Then the main thread uses WaitForSingleObject() to give the worker time to finish up.