|P is for Practical|
However, since the Windows program does not routinely close at the end of its processing, the execution never returns to the script.
What is the program, and what do you have to do manually to cause it to close?
If the program you are trying to control is a command line program that requires some additional (command line) keyboard input -- say, "quit\n" -- in order for it to terminate, the solution required is usually relatively simple.
If however, the program is a GUI program that requires mouse (or keyboard input to the application window), that is somewhat harder. Still possible, but it would require more information.
The easiest way to supply us with the information we need to help you, is to tell use what the program is so that we can test our solutions before replying. This assumes that it is a program that comes with the OS, or is freely available for download somewhere on the web.
If the program is proprietary application; or costs money to obtain, be prepared for an extended Q&A session while we work out what you can do to control it.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.