title: How to cancel the shutdown event of PC?
body: <p>I am making an application in which i want to execute some database queries just before system get shut down. I am using this code -</p>
  
  <pre><code>static void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)
  {
          e.Cancel = true;
          MessageBox.Show("Shut down canceled");
  }
  </code></pre>
  
  <p>I did execute this application and tried to shut down the system and this code captured the shut down event also but the problem is after showing message box it shows this screen also- [I can't post the image as i don't have 10 points.]</p>
  
  <p>it shows the name of my application that stopped the system to get shut down and it also provide "Force Shut down button" , i dont want this screen to be displayed as user can forcefully shut down the system before completion of execution of my queries.</p>
  
  <p>Need expert advices on this, thanks a lot in advance.</p>