I need to close all current **modal popups** and log out the user in ionic 2 application when the device goes to idle.

I used following methods to close popups in the home component.

```
this.viewController.dismiss().then(_ => {
  console.log("modal dismiss");
}).catch(error => {
  console.log(error)
});

```

and

```
this.navController.popAll().then(_ => {
  console.log("modal dismiss");
}).catch(error => {
 console.log(error);
})

```

But it throws following error
***You can't remove all pages in the navigation stack. nav.pop() is probably called too many times.***

and does not close any popup. Anyone knows how to do it?