code: public SceneManager setWindowForTerminating(Window window) {
      this.window = window;
      window.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
          terminate();
        }
  
        @Override
        public void windowClosed(WindowEvent e) {
          terminate();
        }
      });
      return this;
    }
docs: Sets the specified window. The window will be disposed when terminating this manager. This
  manager will also be terminated when closing the window.
  
  @param window the window to be added a window listener