Maybe once the iframe is out of the viewport, the system app could resize its height to 0, this way the app could wait for the resize event and then call `window.close()`.