#55 – Application.ShutdownMode

The WPF Application class has a ShutdownMode property that indicates when an application should terminate, based on which windows are closed.

By default, the value of this property is ShutdownMode.OnLastWindowClose.  This indicates that the application will terminate after you’ve closed all of its windows.

You can also set the property to ShutdownMode.OnMainWindowClose.  When you do this, your application will terminate as soon as you close its main window, which will automatically close any other open windows that the application created.