Im getting mad with Vaadin to detect a detach nothing build-in works pretty good, especially if a open socket in background is running.
Finally, this code does the magic.
Thanks to pierre0303 at @Vaadin forum.
JavaScript.getCurrent().addFunction("aboutToClose", new JavaScriptFunction() { @Override public void call(JsonArray arguments) { // TODO Auto-generated method stub detach(); } }); Page.getCurrent().getJavaScript().execute("window.onbeforeunload = function (e) { var e = e || window.event; aboutToClose(); return; };");
Reference