title: What is the best way to detect all ways of closing a form?
body: <p>I have a form that i close using <code>End</code> several times in my code. I want to do a command to save settings when I do this called <code>VarsToIni()</code> which takes some public variables and saves them in an INI file. I have tried putting it in the main window's FormClosing (which stays open throughout) and this only works when you close from pressing the X button not from my <code>End</code> statement.</p>