Greets,
there are several ways to close a debuggee.
The natural way is, that win32 app should cleanup before closing. For instance closing files, handles and freeing memory, unloading DLLs, writing registry or ini file whatever...
I would suggest the following steps for windows applications:
1. use PostMessage() to post WM_QUIT to main application window
if that fails (no message processing, hung whatever), the debugger should:
2. try to call the ExitProcess API on the debuggee's behalf
2.1. create a thread in the debuggee (CreateRemoteThread) and call ExitProcess
2.2. use SetThreadContext to let the target process/thread call ExitProcess()
(both are clean ways, 2.2. maybe a bit tricky)
if that fails, the debugger should:
3. Terminate its debugging thread - which will in turn close the debuggee's main thread.
(this behavior is by OS design)
if that fails, the debugger should:
4. TerminateProcess() - extreme brutal and should only be used as last resort
For console apps (no message queue), step 1. can be omitted

.
Hope this helps...
Regards,
Anastasius Focht