Move the msgBox code from application close events and to your main page. Override the back key enable event and put your code there. This was done on 7.x:
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e) { if (MessageBox.Show("Do you want to exit XXXXX?", "Application Closing", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel) {
FYI - on WP8, it looks like you need to send the MsgBox Show to a new thread.
This raises a request before the application really begins to close in the event model. If the user accepts the return key, then pressing the button is allowed, otherwise cancel it. You cannot redefine pressing the home button; it should always go to the main screen immediately. You should look at background agents to save your timer code using the suspend / resume function.
Inkog source share