Hi Diego,
Even if you click the X icon system will trigger the assigned close event.
Are you providing any buttons in popup? If there are buttons you can differentiate the button clikc on the X icon click by using the simple outbound plug name from the window.
Other option if you are receiving any collection from the popup then you add a check for the collection bound, In case of button click system will get collection and if it is X icon click system will not have any collection.
Best Regards,
Dharmakasi.