An UWP app which runs on desktop can be closed from the top X button but it doesn\'t have any event for it. It is known that on phones and tablets an app should rely on
This code helps you -
In App.xaml.cs
...
using Windows.ApplicationModel;
...
public App()
{
InitializeComponent();
this.Suspending += OnSuspending;
}
...
private void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
//Add your logic here, if any
deferral.Complete();
}
Thanks!!!