SDL_thread hangs on shutdown in winxp

Hello List

I have just modified a program of mine to use SDL_threads.
In Unix it runs and quits nice, but in windows xp the program hangs when I
quit
and I can’t figure out why…

I close the program like this:

if(bRunning){ // bRunning == true means that a thread has been spawned.
    bRunning = false; // setting to false means that the thread function

will quit.
SDL_UnlockMutex(mutex);
SDL_WaitThread(thread, NULL);
SDL_DestroyMutex(mutex);
}

Am I doing something wrong?

/Jacob Kolding