Is there any way to detect current UWP going to exit? (close by user or kill the process)
I want to send some request to the server about the appli
There is no way to detect such case or to prevent user from terminating your app. If you want to save the state or do something before exit, use Suspending event:
The Suspending event is the only indication your app will receive prior to termination (if it happens). Because of this, you should store enough session state (such as the current article being read or the current movie playback position) to recreate the exact same experience during activation. The guidance for content creation apps is to save a user’s work early and often but also commit one final save during Suspending. Saving data prior to suspension is useful because the Suspending event handler has only 5 seconds to complete its operation.
Just remember about limited time.
In fact there are two other events that will be fired (in mobile case, when user holds back button and goes to task switcher): Window.VisibilityChanged and Windows.Activated, but they are also fired when user change the app, show prompt and so on - and there is no way to distinguish those situations.