Search notes:

PowerShell: Office COM object might leave running process even after calling .Quit()

When an Office COM automation object is created, it might leave a running process after calling .quit(). This is demonstrated in the following example.
First, we verify that there is no running Excel process:
PS C:\> get-process excel 2>$null
The Excel COM-object is created:
PS C:\> $excel = new-object -com excel.application
PS C:\> $excel.visible = $true
Calling quit() on the object makes the GUI of the application disappear:
PS C:\> $excel.quit()
However, the process is still running:
PS C:\> get-process excel 2>$null

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
   1029      52   120980      83156       1.91  11276   1 EXCEL
Setting the variable $excel to $null doesn't eliminate the process, either:
PS C:\> $excel = $null
PS C:\> get-process excel 2>$null
Only removing the variable $excel kills the process:
PS C:\> remove-variable excel
PS C:\> get-process excel 2>$null

Index