title: Prevent Excel from quitting
body: <p>I'm missing an <code>Excel.Application.Quit</code> or an <code>Excel.Application.BeforeQuit</code> event. <strong>Does anybody know a workaround to mimic these events?</strong></p>
  
  <p>I access Excel from a C# WinForms application via COM Interop. Given an <code>Excel.Application</code> object, how can I:</p>
  
  <ol>
  <li>Preferrably prevent Excel from quitting?</li>
  <li>If this is not possible, how can I at least <em>notice</em> when Excel is quit?</li>
  </ol>
  
  <p><strong>Please note:</strong> Since I have a COM reference to the <code>Excel.Application</code>, <strong>the Excel process <em>does not</em> exit</strong> when Excel is "quit" by the user. Although this sounds contradictory, that's how it is. By "quit" I mean that the user hits "Quit" or the "cross button" at the top right corner of the window. The window closes, the files are unloaded, the add-ins are unloaded and whatever stuff Excel does apart from that which I have no clue of. But I can still use the <code>Application</code> object to "revive" the process and make Excel visible again, though the add-ins are then missing, and I have no certainty about what else is in an undefined state.</p>
  
  <p>To get rid of this problem, I would like to either Cancel the Quit at the very start (Think of a <code>BeforeQuit</code> <code>Cancel = true</code> if it existed), or at least be notified when Excel is quit, so I can release the COM objects and make the process really exit, and next time I need Excel again, I will know that I need to start it up first.</p>
  
  <p>Unfortunately it's a vicious circle: <strong>As long as Excel runs, I need the COM objects</strong>. So I can't dispose of them <em>before</em> Excel is quit. On the other hand, as long as the COM objects are there, the process doesn't exit even if Excel pretends to quit, so I cannot wait for a process exit event or similar.</p>
  
  <p>I have the unpleasing feeling that I'm going to bash my head against a brick wall...</p>