title: Await task on application exit
body: <p>I have an app where it records video. So far so good, but if the user exits the app (X button or Alt + F4 or w/e) the video get corrupted (saved in chunks). Is there an event where I can capture such closing event and <code>await a Task</code> to finish? I've tried <code>Application.Current.Dispatcher.ShutdownStarted</code> and <strong>it works</strong> for small videos, but I'm not sure if its reliable since the video can be really long. The app gets closed immediately, but I'm not sure if still awaits the <code>Task</code> in the background and that could be the reason why it works. </p>
  
  <p>Advice? </p>