I had this problem too. The order which I closed and released objects seemed to fix it. Modify this to your variable names and objects. Notice I start with the worksheet release, then workbook, then workbooks collection then finally the app. If you have even one COM object that you don't release, the excel process will stay open. Gotta love interop. For the code below I put a call to the ReleaseObjects() function in every exception handle(in case of error) and when my process is done.
public void ReleaseObjects()
{
while (System.Runtime.InteropServices.Marshal.ReleaseComObject(_currentSheet) > 0) { }
_currentSheet = null;
while (System.Runtime.InteropServices.Marshal.ReleaseComObject(_excelWorkBook) > 0) { }
_excelWorkBook = null;
while (System.Runtime.InteropServices.Marshal.ReleaseComObject(_excelWorkBooks) > 0) { }
_excelWorkBooks = null;
GarbageCollect();
_excelApp.Quit();
while (System.Runtime.InteropServices.Marshal.ReleaseComObject(_excelApp) > 0) { }
_excelApp = null;
GarbageCollect();
}
public static void GarbageCollect()
{
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
}