title: VB.Net Office Interop - Excel process doesn't close
body: <p>Closing an excel using microsoft.office.interop.excel to release the ranges, sheets and workbook doesn't close the process in Windows.</p>
  <p>I can fully close all excel instances but do not know if the user has another excel instance running at the same time.</p>
  <p>Here's everything I've tried</p>
  <pre><code>Marshal.ReleaseComObject(myWorksheet)
  Marshal.FinalReleaseComObject(myWorksheet)
  Marshal.ReleaseComObject(xlRange)
  Marshal.FinalReleaseComObject(xlRange)
  Marshal.ReleaseComObject(.activeworkbook)
  Marshal.FinalReleaseComObject(.activeworkbook)
  Marshal.ReleaseComObject(excelApplication)
  Marshal.FinalReleaseComObject(excelApplication)
  MSExcelControl.QuitExcel()
  GC.Collect()
  GC.WaitForPendingFinalizers()
  GC.Collect()
  GC.WaitForPendingFinalizers()
  </code></pre>
  <hr />
  <pre><code>Friend Shared Sub QuitExcel()
      If Not getExcelProcessID = -1 Then
          If Not excelApp Is Nothing Then
              'Close and quit
              With excelApp
                  Try
                      Do Until .Workbooks.Count = 0
                          'Close all open documents without saving
                          .Workbooks(1).Close(SaveChanges:=0)
                      Loop
                  Catch exExcel As Exception
                      'Do nothing
                  End Try
                  Try
                      .ActiveWorkbook.Close(SaveChanges:=0)
                  Catch ex As Exception
                      'Do nothing
                  End Try
  
                  Try
                      .Quit()
                  Catch ex As Exception
                      'Do nothing
                  Finally
                      myExcelProcessID = -1
                  End Try
              End With
              excelApp = Nothing
          End If
      End If
  End Sub
  </code></pre>