private void processSessionCompleted() {
    TerminalWrapperPanel thisPanel = getWrapperPanel();
    if (thisPanel.getParent() instanceof Splitter splitter) {
      TerminalWidget nextToFocus = myTerminalWidget.hasFocus() ? getNextSplitTerminal(true) : null;
      TerminalWrapperPanel parent = getSplitterParent(splitter);
      TerminalWrapperPanel otherPanel = splitter.getFirstComponent().equals(thisPanel) ? (TerminalWrapperPanel)splitter.getSecondComponent()
                                                                                       : (TerminalWrapperPanel)splitter.getFirstComponent();
      parent.transferChildFrom(otherPanel);
      if (nextToFocus != null) {
        nextToFocus.requestFocus();
      }
      cleanup();
      Disposer.dispose(myTerminalWidget);
    }
    else {
      processSingleTerminalCompleted();
    }
  }
private void processSessionCompleted()