When a user leaves the GWT app, I would like to open a confirm dialog and offer them the choice to stay, i.e. Confirm(\"are you sure you want to leave this page\", \"yes\",
You have to create a CloseHandler and register it on the Window:
Window.addWindowClosingHandler(handler)
EDIT: Fixed method name. See aem comment and answer.