title: Best way to dismiss a modal view from app delegate
body: <p>Here is what I'm trying to do.
  I'm creating a routing app that should handle request from the Apple map app. The map app does so by sending the following message to the app delegate</p>
  
  <p><code>- (BOOL) application: (UIApplication *) application
  openURL:(NSURL *) url
  sourcApplication:(NSString *)sourceApplication
  annotation:(id)annotation</code></p>
  
  <p>The thing is, my app could already be executing and be any state at this point. It could be several layers deep in the navigation stack, it could also be that there is just one root controller in the navigation stack, but a modal view is currently covering over it.</p>
  
  <p>Where ever it is, I want to pop all view controllers to keep just one top-most view controller, and this I know how to do so. But I also want to dismiss any modal view if it is there, and I don't know how to do it.</p>
  
  <p>How would I know if a modal view (or if there is more than one possible model views, which isn't the case, but I'm asking it for the sake of the question.) is covering it? And I want to dismiss it? Is it accessible from the app delegate directly? Right now I'm just keeping a pointer reference of the modal view controller in that top-most view controller of the navigation stack, and dismiss the view controller if the reference is not nil. The app delegate simply asks the top-most view controller to do this job.</p>
  
  <p>Is this proper?</p>