How to Close a WPF application programmatically?

Shutdown method of Application class in WPF is used to stop an application immediately regardless if Close event is fired or not. Shutdown method is called implicitly on Window close and MainWindow close events when Shutdown mode is set to OnLastWindowClose, OnMainWindowClose respectively.

Application curApp = Application.Current;
curApp.Shutdown();