Excel is generally the worst offender this way – there have been problems
with it not shutting down when told to that go back a very long time – but
there definitely are other ActiveX applications that exhibit this kind of
behavior. Since ActiveX applications are generally rare and each have their
own quirks, I usually test whether they shut down in different situations
when using them from PowerShell by keeping an eye on the process list, then
release the object if they don’t shut down correctly.
Unfortunately, this isn’t all that useful if you’re keeping an application
around to use during a PowerShell session. In those cases, I’ve noticed that
even some of the better-behaved ActiveX applications don’t work the way we
might want. For example, some of the better-behaved ActiveX applications
will indeed shut down automatically if they don’t have an open, modified
document when you close PowerShell by typing exit, but will hang around if
you close PS with the "X" at the top of the shell window. My general rule of
thumb is to always unhide ActiveX applications and minimize them. This at
least ensures that I can see and close them if I exit PS the wrong way or
lose connection to the app somehow.
One way in Power Shell to kill the process is;
Stop-Process -name EXCEL
Another is to try to release the com object after quiting:
spps -n excel
I am sure that there are others.