There is a "Close Similar Tabs" extension for Firefox
https://addons.mozilla.org/en-US/firefox/addon/close-similar...
Personally, I usually prune a window with many open tabs, usually created after a search for a solution or workaround for a bug, down to the initial search(es) and any useful results, then bookmark any remaining tabs into a folder, in the hope that a future search for the same topic might provoke an auto-suggestion, and in the usually vain hope that I might someday curate all the folders for related topics into a coherent hierarchy.