title: Closing PowerPoint After Slidshow finished
body: <p>I use the following code to show and close a PowerPoint-slide:</p>
  
  <pre><code>private void StartSlideshow() {
      var opApp = new Microsoft.Office.Interop.PowerPoint.Application();
      ppApp.SlideShowEnd += PpApp_SlideShowEnd;
  
      var ppPresentation = ppApp.Presentations.Open(_filename, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);
      var settings = ppPresentation.SlideShowSettings;
      settings.Run();
  }
  
  private void PpApp_SlideShowEnd(Microsoft.Office.Interop.PowerPoint.Presentation Pres)  {
      Pres.Saved = Microsoft.Office.Core.MsoTriState.msoTrue;
      Pres.Close();
      Pres.Application.Quit();
  }
  </code></pre>
  
  <p>Now when I try to close the application (<code>Pres.Application.Quit()</code>) I receive the following Exception:</p>
  
  <pre><code>Application (unknown member) : Invalid request.  This operation cannot be performed in this event handler.
  </code></pre>
  
  <p>I have a clue why this fails (trying to kill the application that created the event), but if I don't run this command, PowerPoint stays open.</p>
  
  <p>What is the right way to solve this?</p>