code: public static <M> Subscription destroyOnClose(final Window window, final AbstractViewController<M> viewBinder) {
          Assert.requireNonNull(window, "window");
          Assert.requireNonNull(viewBinder, "viewBinder");
          final EventHandler<WindowEvent> handler = e -> viewBinder.destroy();
          window.addEventFilter(WindowEvent.WINDOW_HIDDEN, handler);
          return () -> window.removeEventFilter(WindowEvent.WINDOW_HIDDEN, handler);
      }
docs: The method will register an event handler to the window that will automatically call the {@link AbstractViewController#destroy()}
  method when the windows becomes hidden.
  @param window the window
  @param viewBinder the view binder
  @param <M> the model type
  @return a subscription to unsubsribe / deregister the handler.