To add to Barney-15E's excellent notes, you don't need to do anything.
Nothing was downloaded to, or installed on your Mac. There is also no software in the world that can determine what is on a remote computer through a web browser. As such, any and all such pop-ups are automatically fake.
What they all have in common is the pop-up, which is designed to keep you stuck on the page. To fully explain how these popups work on the Mac (and Windows):
1) You hit a bad web site and the scary sounding popup appears.
2) You click OK or whatever button is there to try and dismiss it. The popup seems to be unresponsive, or comes back after a very brief time off the screen.
3) This happens because of a JavaScript action they're using. JavaScript (no relation at all to Java) is used extensively on the web. Much of what we take for granted wouldn't work if you turned it off in a web browser's preferences. Like the buttons across the top of this page. Anything on a page that changes when you move your mouse over or across it is JavaScript in action. In this case, the mouseover command.
4) What these scammers use is another JavaScript action to "do on exit". In the case of these popups, you really are closing it when you click the button, but the final HTML command of the popup is a JavaScript "do on exit". And the "what to do" is to display the same popup.
5) Safari, and pretty much all web browsers force you to attend to the button on a popup before it will let you do anything else. Which is why you can't get to the preferences or other tabs. So there you are, stuck in a loop of closing the popup, only to have it immediately display again. The crooks are using a simple built-in function of all web browsers to make your web browser appear to be stuck. No malware of any kind is necessary to accomplish this. Just a browser with JavaScript enabled. And it pretty much has to be on in order to use virtually any web site.
Apple did add a way to Safari to make it easier to get out of these pop-ups. After clicking a couple of times, you get a different button that allow you to get off the page. The scammers almost immediately worked around that by adding a bunch of blank lines after their scam text to make the pop-up really tall, which forces the buttons out of view. You can still get rid of it, but you then just follow the instructions to Force Quit Safari and relaunch it with the Shift key held down.