title: WPF App Doesn't Shut Down When Closing Main Window
body: <p>I'm used to WinForms programming in Visual Studio, but I wanted to give WPF a try.</p>
  
  <p>I added another window to my project, called Window01. The main window is called MainWindow. Before the <code>public MainWindow()</code> constructor I declare Window01:</p>
  
  <pre><code>Window01 w1;
  </code></pre>
  
  <p>Now I instantiate this window in:</p>
  
  <pre><code>private void Window_Loaded(object sender, RoutedEventArgs e)
  {
      w1 = new Window01();            
  }
  </code></pre>
  
  <p>I have a button where the window is shown: <code>w1.ShowDialog();</code>.</p>
  
  <p>The 'funny' thing here is the fact that if I start the application (with debugging) and exit it a few seconds after (I don't do anything in the application), Visual Studio doesn't stop debugging as if the application is still running.</p>
  
  <p>If I move the line <code>w1 = new Window01();</code> to the button click method, meaning just above <code>ShowDialog()</code>, Visual Studio is behaving properly - that is, the debugging stops when I exit the application.</p>
  
  <p>Why this strange behaviour?</p>