It’s really very simple – everything you need is in ~/Libaray/Safari/LastSession.plist just quit Safari and restore that file from when it was good and you’re done.
What’s this about?
Well I tend to use open Safari windows/tabs to help keep me focused on foreground tasks while minimising backround/interesting/to-do articles etc. Occasionally I forget to restore all my windows after restarting Safari for a quick session (usually whilst preparing for shutdown/restart/software update).
Next time you try to restore all your windows and don’t get what you expected – remind yourself this is why that extra Time Machine disk was such a useful investment.
Hope this helps.