Checking if an Ionic popover is open

I would like to check if the popover is open, so that when the user clicks the back button the popover gets dismissed, i managed to dismiss it without checking if it’s open, but it throws an exception when it’s not open, thank you in advance