Sorry, I should have been more specific last time. The code should be attached to the symbol for which we are creating the instance at runtime. I've updated your sample with the new code and shared it here - Dropbox - popupIssue.zip, you can use it for reference. Please note that the behavior will be fired only when mouseleave fires for the popup, however if user never takes the mouse inside the popup then it will still be active. I've attached a sample code to dismiss the popup when you click on stage, you can use the same as per your requirement.
Also, the code earlier could create multiple popups. I have put a check to avoid that.
-Dharmendra