diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Client.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Client.java
index 9888e7b0f6c338c7f1af4d1bad2b14215954d0cc..8eaa9a147dfdc95cc0ca3bd384216f90bdd08144 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Client.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Client.java
@@ -283,7 +283,7 @@ public class Client implements EntryPoint, ValueChangeHandler<String>
                 viewContext.initDisplaySettingsManager();
                 dispatcher.dispatch(AppEvents.INIT);
                 afterInitAction.execute();
-                GWTUtils.setAllowConfirmOnExit(true);
+                GWTUtils.setConfirmExitMessage();
             }
         }
     }
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/menu/user/action/LogoutCallback.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/menu/user/action/LogoutCallback.java
index 56615094b8cec37ee0fe0f30ae0f86bd8b985ef9..d42aae839ccd2390ae98295fd7ad9cc660ce9c39 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/menu/user/action/LogoutCallback.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/menu/user/action/LogoutCallback.java
@@ -26,19 +26,19 @@ final class LogoutCallback extends AbstractAsyncCallback<Void>
     LogoutCallback(IViewContext<ICommonClientServiceAsync> viewContext)
     {
         super(viewContext);
-        System.out.println("CREATE "+this);
+        System.out.println("CREATE " + this);
     }
 
     @Override
     protected void finalize() throws Throwable
     {
-        System.out.println("FINALIZE "+this);
+        System.out.println("FINALIZE " + this);
     }
 
     @Override
     public final void process(final Void result)
     {
         viewContext.getPageController().reload(true);
-        GWTUtils.setAllowConfirmOnExit(false);
+        GWTUtils.removeConfirmExitMessage();
     }
 }
\ No newline at end of file
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/GWTUtils.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/GWTUtils.java
index 526cd185570a2280cc87b51365b89c9327f50553..92341ddd47bb982e9c252a943419aef456969e58 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/GWTUtils.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/GWTUtils.java
@@ -29,6 +29,9 @@ import com.extjs.gxt.ui.client.widget.tips.ToolTipConfig;
 import com.extjs.gxt.ui.client.widget.treegrid.TreeGrid;
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.DeferredCommand;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.Window.ClosingEvent;
+import com.google.gwt.user.client.Window.ClosingHandler;
 import com.google.gwt.user.client.ui.ListBox;
 
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.model.ModelDataPropertyNames;
@@ -268,6 +271,32 @@ public final class GWTUtils
                 "$", "-DOLLAR-");
     }
 
+    // confirm on exit message
+
+    private final static String CONFIRM_EXIT_MSG =
+            "WARNING: By doing this you will in fact leave openBIS!";
+
+    public final static void setConfirmExitMessage()
+    {
+        setConfirmExitMessage(CONFIRM_EXIT_MSG);
+    }
+
+    public final static void removeConfirmExitMessage()
+    {
+        setConfirmExitMessage(null);
+    }
+
+    private final static void setConfirmExitMessage(final String msgOrNull)
+    {
+        Window.addWindowClosingHandler(new ClosingHandler()
+            {
+                public void onWindowClosing(ClosingEvent event)
+                {
+                    event.setMessage(msgOrNull);
+                }
+            });
+    }
+
     //
     // native JavaScript
     //
@@ -284,15 +313,6 @@ public final class GWTUtils
         return search.indexOf("?") == 0 ? search.substring(1) : search;
     }-*/;
 
-    /**
-     * Depending on specified <var>allowConfirmOnExit</var> when user tries to exit application
-     * confirmation dialog will or will not appear.
-     */
-    public final static native void setAllowConfirmOnExit(boolean allowConfirmOnExit)
-    /*-{
-        $wnd.allowConfirmOnExit = allowConfirmOnExit;
-    }-*/;
-
     /**
      * Tooltip template displayed when mouse is over drop down list.
      */
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/index.html b/openbis/source/java/ch/systemsx/cisd/openbis/public/index.html
index edd85dd665da5f69669691fc6bc2b1d292b18bea..dfd1d9129fa2190ab040a421096928d1d8fed8af 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/public/index.html
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/index.html
@@ -6,23 +6,12 @@
 <link rel="shortcut icon" href="images/favicon.ico" />
 <link rel="icon" type="image/png" href="images/favicon.png" />
 <link rel="stylesheet" type="text/css" href="resources/css/gxt-all.css" />
+
 <!--
 // This script loads your compiled module. If you add any GWT meta tags, they must be added before this line.
 -->
 <script language="javascript"
-	src="ch.systemsx.cisd.openbis.OpenBIS.nocache.js"></script>
-<script language="JavaScript">
-	// confirmation on exit depends on whether user is logged in
-	var allowConfirmOnExit = false; 
-  window.onbeforeunload = confirmExit;
-  function confirmExit()
-  {
-    if (allowConfirmOnExit) {
-      return "WARNING: By doing this you will in fact leave openBIS!";
-    }
-  }  
-</script>
-
+    src="ch.systemsx.cisd.openbis.OpenBIS.nocache.js"></script>
 </head>
 <!--
 // The body can have arbitrary html, or you can leave the body empty if you want to create a completely dynamic ui.