title: Is there any way to capture application exit event in vb.net windows form system?
body: <p>In C#, I used to capture the application exit event with the following code in program.cs.</p>
  
  <pre><code>   static void OnProcessExit(object sender, EventArgs e)
      {
          string message = "The application was closed at :" + DateTime.Now.ToString() + "."; 
  
  
      }
  </code></pre>
  
  <p>What is the equivalent of this in VB.NET?</p>
  
  <p>I want to close the database connection if it is open by any chance in the application exit event.</p>