Embedded shall be removed wenn "close window" pushed in Webpage

I have to use forms delivered by another application in an Embedded-element (what means a browser window). The user shall fill in the form and transmit, after that he can click a close button (that one, which does not work in all browsers).

I would be very happy, if i could use that button as event trigger to remove the embedded component. I tried to add a close listener to the Embedded (what does not want to work), and also added a close listener to the containing window (what just did not work).

So, ist there a possible way to achieve that goal (removing the embedded from the window when clicking the close-button in contained html)?