Application which hosts Windows Media Player OCX may not be able to fully quit
You may be occasional encounter such symptom: your window based application that hosts a WMP OCX control does not fully quit after you close the window. The window got disappear successfully, but you still can find the process running in task manager. If you're playing something in Windows Media Player 11 and you still can hear music after you close it, this is not the same story that I wanted to tell, you may want to read this KB.
If you attach a debugger to the "phantom" process, and check the call stack of the main thread, you will be finding it's still in the message loop of the main window. What happened? Since you clicked the exit button, the message loop should had been quitted. Does this mean system forgot to send WM_QUIT to the application? It's not so complicated, just a very simple reason, the main window did not receive the WM_QUIT message. How could it happen? There is a message pump and there is some code to handle different return value of GetMessage. In the own WMP OCX host window code, you also called PostQuitMessage in the WM_DESTORY. You may also consulted WMPHOST sample which ships with WMP SDK. You cannot find main difference between your code and the sample code. But WMPHOST just works fine on your machine.
The symptom only happens with WMP 10 or eariler. Yes, it's a bug and had been fixed in WMP11. But why only your application suffers the pain, does Microsoft use any magic in WMPHOST sample? There is no magic. The solution is to handle WM_NCDESTORY. Because when WMP OCX receives WM_QUIT, it eats the message and does not post to other window of the thread, so the main window may never know it needs to quit. You can handle WM_NCDESTORY in the OCX host window's code, call PostQuitMessage in it and it will post the quit message to the main window inerrably. If you look WMPHOST code carefully, you'll find it just use this way to get around the bug.
This symptom may not always happens if the main window receives WM_QUIT message before WMP OCX messge pump eats it.