I'm pretty new to C# development and I'm trying to run some code before the user quits the application completely. I tried to look online but did not get anything. Here is my code and it's not working. Thanks:
namespace WpfApp1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            Console.WriteLine("Hello World!");
        }
        void DataWindow_Closing(object sender, CancelEventArgs e)
        {
            Console.WriteLine("Goodbey World!");
        }
    }
}
 
     
     
     
    