@Override
	protected void dispose() {
		tool.removeContextListener(this);
		ToolOptions opt = tool.getOptions(ToolConstants.TOOL_OPTIONS);
		opt.removeOptionsChangeListener(this);

		opt = tool.getOptions(SearchConstants.SEARCH_OPTION_NAME);
		opt.removeOptionsChangeListener(this);

		navigatable = null;

		if (searchDialog != null) {

			if (searchDialog.isVisible()) {
				TaskMonitor taskMonitor = searchDialog.getTaskMonitorComponent();
				taskMonitor.cancel();
				if (searchAllTaskMonitor != null) {
					searchAllTaskMonitor.cancel();
				}
			}

			searchDialog.dispose();
		}

		if (currentTask != null) {
			currentTask.cancel();
		}
	}
The constructor for the SearchTextPlugin.

@param plugintool The tool required by this plugin.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/SearchTextPlugin.java