Easiest way to stop this from happening is to use ublock origin to block all third party request on your instance.
One way to do this is via dynamic filtering. This is for advanced users so be sure to read the info page: https://github.com/gorhill/uBlock/wiki/Dynamic-filtering
(Consider backing up your ublock settings before doing this)
If you are using lemmy.ml your rule would be this:
lemmy.ml * 3p block
if you're using another instance then change the domain or use both rules cause you might end up visiting the others as well. Note that adding this rule wont work unless enable advanced features in ublock origin.
EDIT: THIS MIGHT BREAK THINGS ON YOUR INSTANCE, its recommended to learn how to use dynamic filtering to unbreak it: https://github.com/gorhill/uBlock/wiki/Dynamic-filtering:-quick-guide If it breaks stuff just remove that rule.
You could also block it using static filters but I can't remember how to do that exactly, if you know please reply below.
Only the last three or so windows though, so if you got a few pop-ups before you press that you might be screwed...
...unless you have backups of an old session file, then you can use this tool to restore a list of those tabs: https://www.jeffersonscher.com/ffu/scrounger.html
There is also this handy addon for saving backups of windows like that to a txt list of urls: https://addons.mozilla.org/en-GB/firefox/addon/urls-list/