This missing feature is still in my muscle memory and would be a great quality of life feature. It's a shame there isn't a clean way of doing it via an extension any more else I'm sure someone would have created it.
There used to be a great plug-in that enabled this Safari-like feature in Firefox but it broke in version 135. https://addons.mozilla.org/en-GB/firefox/addon/back-to-close-we/ I assume it make use of manipulating the history entries but this is no ...