If the pop-up is opened using a button / on change / navigation / etc., you could call a micro- or nanoflow instead of directly opening the popup. In that flow, you could then create a non-persistable helper object with a boolean that stores whether or not the pop-up is open before actually opening the pop-up. That boolean could then be used to do whatever you want to do based on whether or not the pop-up exists.