Hi Diego,
Little confusion with the above statement, Here i am summerising your requirement.
You have added a button when user clicks on it, system will raise a popup you want to add code on close event of the popup, is my understanding correct with your requirement?
Create close event in the same view where you have added button to open popup, if you have already created event then check in do_handle_event of the same view and check whether popup close event is triggering.
Best Regards,
Dharmakasi.