Sorry about that, my mistake.

What doesn't work is the WaitForSingleObject because it is waiting on a process that doesn't quit. I need a way to find out when the window is closed so that the process can be terminated through TerminateProcess.