Exit out of a Windows Phone Application
Scenarios for needing Exit
The two most common scenarios people cite when asking for an Exit method are because (a) the user failed accept a EULA, login to an account, or something else that renders the application inoperable, or (b) the application is in an unstable state due to unexpected errors, etc. and needs to be shut down.
The solution: Throwing Exceptions to Exit your Silverlight App
Peter Torr has a great blog post here about all the various scenarios you may want to exit a WP7 application and each of their side affects. I would encourage you to read his post to learn more about this topic

This would be of better help:
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
MessageBoxResult res = MessageBox.Show(“Are you sure you want to exit?”, “Exit?”, MessageBoxButton.OKCancel);
if (res == MessageBoxResult.OK)
{
e.Cancel = false;
base.OnBackKeyPress(e);
}
}
More information at http://austinejei.blogspot.com/2012/06/exiting-wp7-application.html
In wp8 you can exit by
Application.Current.Terminate();