title: Proper way of closing Excel application
body: <p>I'm writing an application, which accesses Excel file with this code:</p>
  
  <pre><code>RBTApplication = new Excel.Application();
  RBTWorkbooks = RBTApplication.Workbooks;
  RBTWorkbook = RBTApplication.Workbooks.Open(
      RBTDataSet.Instance.FilePath, 0, true, 5, "", "", true,
      Microsoft.Office.Interop.Excel.XlPlatform.xlWindows,
      "\t", true, false, 0, true, 1, 0 );
  RBTWorksheet = (Excel.Worksheet)RBTWorkbook.Worksheets.get_Item( 1 );
  RBTRange = RBTWorksheet.UsedRange;
  </code></pre>
  
  <p>After I load data that I need, I try to close Excel application with this piece of code:</p>
  
  <pre><code>RBTWorkbook.Close();
  RBTApplication.Quit();
  RBTWorksheet.ReleaseComObject();
  RBTWorkbook.ReleaseComObject();
  RBTWorkbooks.ReleaseComObject();
  RBTApplication.ReleaseComObject();
  </code></pre>
  
  <p>My problem is that EXCEL.EXE process is still running.
  Simple solution like killing all Excel processes doesn't sound great, as my process can be one of many spreadsheets used at the same time. This one also affects opening new excel spreadsheets - every opens as read only until I don't kill this process.</p>
  
  <p>So ... how to close this application properly OR kill this specific process (is there any way to get PID from COM object ?). I think I've found one (haven't tried) - get list of excell processes before and after opening new ExcellApp, compare lists (get difference), kill specific process knowing its PID. But this solution doesn't seem like a proper way of handling COM objects and other applications from within my app.</p>