Add onCloseWindow event capture. pyjd.setup() returns Browser() object, and you can add an event handler to it to capture as following:

    import pyjd
    import pyjamas.Window

    browser=pyjd.setup(url)
    browser.addCloseHandler(Window.onClosing)