<p>I'm using the Excel interop in C# (<code>ApplicationClass</code>) and have placed the following code in my finally clause:</p>

<pre><code>while (System.Runtime.InteropServices.Marshal.ReleaseComObject(excelSheet) != 0) { }
excelSheet = null;
GC.Collect();
GC.WaitForPendingFinalizers();
</code></pre>

<p>Although this kind of works, the <code>Excel.exe</code> process is still in the background even after I close Excel. It is only released once my application is manually closed.</p>

<p>What am I doing wrong, or is there an alternative to ensure interop objects are properly disposed of?</p>

This worked for a project I was working on:
```
```
excelApp.Quit();
Marshal.ReleaseComObject (excelWB);
Marshal.ReleaseComObject (excelApp);
excelApp = null;
```
```
We learned that it was important to set
every
reference to an Excel COM object to null when you were done with it. This included Cells, Sheets, and everything.