title: how to close all ionic 2 modals?
body: <p>I need to close all current <strong>modal popups</strong> and log out the user in ionic 2 application when the device goes to idle.</p>
  
  <p>I used following methods to close popups in the home component.</p>
  
  <pre><code>this.viewController.dismiss().then(_ =&gt; {
    console.log("modal dismiss");
  }).catch(error =&gt; {
    console.log(error)
  });
  </code></pre>
  
  <p>and</p>
  
  <pre><code>this.navController.popAll().then(_ =&gt; {
    console.log("modal dismiss");
  }).catch(error =&gt; {
   console.log(error);
  })
  </code></pre>
  
  <p>But it throws following error
  <strong><em>You can't remove all pages in the navigation stack. nav.pop() is probably called too many times.</em></strong></p>
  
  <p>and does not close any popup. Anyone knows how to do it?</p>