private int closeExtraResultTabs(@Nullable QueryProcessor queryProcessor, boolean confirmClose, boolean keepFirstTab) {
        List<CTabItem> tabsToClose = new ArrayList<>();
        QueryProcessor processor = null;
        for (CTabItem item : resultTabs.getItems()) {
            if (item.getData() instanceof QueryResultsContainer) {
                processor = ((QueryResultsContainer) item.getData()).queryProcessor;
            } else if (item.getData() instanceof QueryProcessor) {
                processor = (QueryProcessor) item.getData();
            }
            if (item.getData() instanceof QueryProcessingComponent && item.getShowClose() && !isPinned(item)) {
                if (queryProcessor != null && queryProcessor != processor) {
                    continue;
                }
                if (queryProcessor != null && queryProcessor.resultContainers.size() < 2 && keepFirstTab) {
                    // Do not remove first tab for this processor
                    continue;
                }
                tabsToClose.add(item);
            } else if (item.getData() instanceof ExplainPlanViewer) {
                tabsToClose.add(item);
            }
        }
        if (tabsToClose.size() > 1 || (tabsToClose.size() == 1 && keepFirstTab)) {
            int confirmResult = IDialogConstants.YES_ID;
            if (confirmClose) {
                confirmResult = ConfirmationDialog.confirmAction(
                    getSite().getShell(),
                    ConfirmationDialog.WARNING,
                    SQLPreferenceConstants.CONFIRM_RESULT_TABS_CLOSE,
                    ConfirmationDialog.QUESTION_WITH_CANCEL,
                    tabsToClose.size()
                );
                if (confirmResult == IDialogConstants.CANCEL_ID || confirmResult < 0) {
                    return IDialogConstants.CANCEL_ID;
                }
            }
            if (confirmResult == IDialogConstants.YES_ID) {
                for (int i = 0; i < tabsToClose.size(); i++) {
                    if (i == 0 && tabsToClose.get(0).getData() instanceof SingleTabQueryProcessor sqp && keepFirstTab) {
                        // to avoid concurrent modification exception
                        List<QueryResultsContainer> results = new ArrayList<>(sqp.getResultContainers());
                        results.stream().skip(1).forEach(QueryResultsContainer::dispose);
                    } else {
                        if (i == 0 && keepFirstTab) {
                            continue;
                        }
                        tabsToClose.get(i).dispose();
                    }
                }
            }
            return confirmResult;
        } else if (tabsToClose.size() == 1) {
            if (tabsToClose.get(0).getData() instanceof SingleTabQueryProcessor sqp) {
                // to avoid concurrent modification exception
                List<QueryResultsContainer> results = new ArrayList<>(sqp.getResultContainers());
                results.forEach(QueryResultsContainer::dispose);
                tabsToClose.get(0).dispose();
            }
        }
        // No need to close anything
        return IDialogConstants.IGNORE_ID;
    }
Obtain the add-in instance by its concrete type
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/SQLEditor.java