private static boolean closeWindow(@NotNull Window window, boolean modalOnly) {
    if (window instanceof IdeFrameImpl || (modalOnly && canBeHiddenBehind(window))) {
      return false;
    }

    if (window instanceof DialogWrapperDialog) {
      ((DialogWrapperDialog)window).getDialogWrapper().doCancelAction();
      return !window.isVisible();
    }

    window.setVisible(false);
    window.dispose();
    return true;
  }
private static boolean closeWindow(@NotNull Window window, boolean modalOnly)