Try to close the window. This has the same effect as a user manually clicking the close button of the window. The web page may cancel the close though. See the close event.