Get the OneTab extension. It'll save and close all those tabs. That way you won't have Firefox crashing during startup once you exceed the number of tabs it can handle (a few thousand).
I have 117 thousand tabs, and it starts up fine. Just adjust your shm ratio.
(I'm kidding)
I've had it function just fine around 9000 tabs.
Doesn't Firefox natively unload tabs these days?
You can also just do tab groups in ffx
Tip: the crashing is caused by certain extensions such as OneTab and All Tabs Helper which for some reason seem to cause all the tabs to load, just when restoring a session. Temporarily disable these extensions before restoring, then you can reenable.