Fix crash if search command is used while searching
Thread safety was only provided by disabling the UI and that breaks
if we use the commands.
Add terminateSearch functions that stop the search without sending
signals and prevent already queued signals from adding matches in the
matches tree.
BUG: 419719