Close all modals?

For our app because it has sensitive information, after 30 mins of not being used we log the user out and push them to the login screen. This works fine except if the user has a modal page open. The background page does log out and go to the login page, but the modal is over the top.
Is there any way to just close down all modals that are open? I know this is a long shot.