code: public void close() {
          if (animation != null) {
              animation.setRate(-1);
              animation.play();
              animation.setOnFinished(e -> {
                  closeDialog();
              });
          } else {
              setOpacity(0);
              setVisible(false);
              closeDialog();
          }
  
      }
docs: close the dialog