In the help files, you can find :

---------------------------------------------------------------------------------
To end the thread, call AfxEndThread from within the thread, or return from the controlling function of the worker thread.
---------------------------------------------------------------------------------

But that isn't possible if the thread is locked by the WaitCommEvent()-function ...