Bugfix: handle window.close()