Popup: Do not proceed with _closePopup() if the popup is no longer the currently-open one. Fixes #6182.
Integration tests: Popup: Make sure the popup emits exactly one "popupafterclose" event upon closing.