title: How to release objects which are created for Excel (C#)
body: <p>I use some objects like workbook, worksheet, app for Excel tasks. After I am done with Excel, I try releasing them by the code below. After all, I still see EXCEL.EXE at Task Manager. Why doesn't it release completely?</p>
  
  <p><strong>My class for Excel tasks:</strong></p>
  
  <pre><code>Excel._Application app = new Excel.Application();
  Excel._Workbook workbook = app.Workbooks.Add(Type.Missing);
  Excel._Worksheet worksheet = null;
  app.Visible = true;
  
  worksheet.Cells[1, 1] = "test string";
  
  workbook.SaveAs("C:\testfile.xlsx");
  
  object misValue = System.Reflection.Missing.Value;
  workbook.Close(true, misValue, misValue);
  app.Quit();
  
  releaseObject(worksheet2);
  releaseObject(workbook);
  releaseObject(app);
  </code></pre>
  
  <p><strong>releaseObject class:</strong></p>
  
  <pre><code>    private void releaseObject(object obj)
      {
          try
          {
              System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
              obj = null;
          }
          catch (Exception ex)
          {
              obj = null;
              MessageBox.Show("Unable to release the Object " + ex.ToString());
          }
          finally
          {
              GC.Collect();
          }
      } 
  </code></pre>
  
  <p><strong>EXCEL.EXE is still at Task Manager:</strong>
  <img src="https://i.stack.imgur.com/Js79T.png" alt="enter image description here"></p>