title: How to exit Windows Phone App without back
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4338589/close-a-wp7-application-programatically">Close a WP7 application programatically?</a>  </p>
  </blockquote>
  
  
  
  <p>I want to show to my user that he needs Internet connection for the application using MessageBox. When he clicks OK I like to exit the application without using BackButton
  Here is the code</p>
  
  <pre><code>try
          {
              response = (HttpWebResponse)request.EndGetResponse(asyncResult);
          }
          catch (Exception e)
          {
  
              System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =&gt;
              {
                  MessageBoxResult m = MessageBox.Show("Потребна е Интернет конекција");
                 if (m == MessageBoxResult.OK)
                 {
                     while (NavigationService.BackStack.Any())
                        NavigationService.RemoveBackEntry();
                      //base.OnBackKeyPress(new System.ComponentModel.CancelEventArgs());
                     NavigationService.GoBack();
                  }
  
  
  
              });
  
  
          }
  </code></pre>
  
  <p>However, the app is not exiting it is trying to connect to the web service</p>
  
  <p>Thanks</p>