Just Place ane event in the xaml code
Closing="Window_Closing"
Then write a event handler for that closing event in .cs page
Code:
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
Application.Current.Shutdown();
}