title: How to kill all threads when WPF app was closed
body: <p>I have a WPF app. I am starting some threads. When I close the app it is still running in the background (I am seeing from Task Manager) because Threads are still running.  I want to kill all threads when the app was closed. Here is the code:</p>
  <pre><code>public partial class MainWindow : Window
  {
      public MainWindow()
      {
          InitializeComponent();
      }
  
      Thread thread;
      private void Button_Click(object sender, RoutedEventArgs e)
      {
          thread = new Thread(new ParameterizedThreadStart(abc));
          thread.Start();
      }
  
      private void abc(object obj)
      {
          Thread.Sleep(10000);
      }
  }
  </code></pre>
  <p>In this case, when I click the button and close the app, it will still be running in the background for 10 seconds. How can I kill all threads on the closing app?</p>