Closing a C# Application (including hidden forms)

There are many times when we develop C# applications, where we make use of several forms. To this end, there are times that we are using the Hide() method for some of these forms thus hiding the forms, but not closing or disposing them.

Nevertheless, in the main form of a program we usually make use of an “Exit” button or another similar control. If the even code used behind this control calls the form to be closed or disposed, the application still runs due to the other hidden forms.


Get Started with .NET Programming Fast and Easy!

Check our online course titled “.NET Programming for Beginners: Windows Forms (C#)” (special limited-time discount included in link).

.NET Programming for Beginners: Windows Forms (C#) - Online Course

Learn how to implement Windows Forms projects in .NET using Visual Studio and C#, how to implement multithreading, how to create deployment packages and installers for your .NET Windows Forms apps using ClickOnce in Visual Studio, and more! 

Many live demonstrations and downloadable resources included!

Enroll Now with Discount!


How to Properly Close a C# Application

In order to totally close a C# application, including the hidden forms, you can use the following command in the event code of the “Exit” control:



Featured Online Courses:


Read Also:


Did you find this article useful and interesting?

Interested in SQL Server Administration? Find hundreds of useful SQL Server administration and troubleshooting articles in 9 Times Microsoft Data Platform MVP, Artemakis’ Artemiou eBook: “Administering SQL Server (Second Edition)“.

Check our other related .NET articles.

Check out our latest software releases!

Subscribe to our newsletter and stay up to date!


Rate this article: 1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)


Reference: (

© 2018 SQLNetHub