Best-Practice for closing 'This Popup'?

Ignition 8.1.20, Perspective:
I'm curious what the best practice is for closing the respective popup which contains a 'Close Popup' button? ...if a popupId is not known? ...if the 'Close Popup' button exists within an Embedded View of that popup?

Per insight from link below, we are using a script action within onActionPerformed of a Button object.

def runAction(self, event):
	system.perspective.closePopup('')

Is it desirable to name the popup Id during closing? If so, is there a clean method of grabbing the popup's Id property?

Perhaps another question would be: What is the specific action that is performed when the built-in "X" is pressed (located in title bar, when 'Show close button' is selected on popup creation)?

I forgot to mention, there is an issue with the aforementioned script we are using, whereby the 'Active Popup' closes instead of the parent popup containing the button.
This issue rears its ugly head only when multiple popups are open, and when the user clicks quickly on the close button of an inactive popup.

The native X button of the Popup does not care about the ID - that's the browser operating on HTML components without regard for their content. If you want Perspective to operate on a Popup, you really need to provide the ID of the Popup. I recommend that every time you open a Popup you do so one of two ways:

  1. Using a Script Action or Popup Action, pass the identifier used for the Popup as a param to the View. Then from within the View, any Button should reference that id param of the View. If you need to have your "close" button in an Embedded View of this View, then you need to continue passing the param down the chain. This is the best approach because No View is responsible for hanging onto some ID that might be changed elsewhere.
popup_id = "ASDF"
system.perspective.openPopup(id=popup_id, view="MyView", params={"id": popup_id})
  1. Hard-code the Popup ID into the View being used. This is a bad approach, but it will work until you change the ID in one location or the other.