YOU are still a mile away from understanding how to use forms. The closing event just does what you want. There is no need to keep calling a close function. Just let the form close the way it is designed to be closed and use the even to decide if you really want to close the form./
See the following which does exactly what you want. It is how forms work. You are trying to think that you have to write code that is already built into the form.
I Here is the documentation that describes what WinForms are and how they are designed to work.
https://docs.microsoft.com/en-us/dotnet ... /winforms/
PowerShell form message displays twice on exit
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.