The following comes from user stevejobsfan0123. I have made minor changes to adapt to this presentation.
Fix Some Browser Pop-ups That Take Over Safari.
Common pop-ups include a message saying the government has seized your computer and you must pay to have it released (often called "Moneypak"), or a phony message saying that your computer has been infected, and you need to call a tech support number (sometimes claiming to be Apple) to get it resolved. First, understand that these pop-ups are not caused by a virus and your computer has not been affected. This "hijack" is limited to your web browser. Also understand that these messages are scams, so do not pay any money, call the listed number, or provide any personal information. This article will outline the solution to dismiss the pop-up.
Quit Safari
Usually, these pop-ups will not go away by either clicking "OK" or "Cancel." Furthermore, several menus in the menu bar may become disabled and show in gray, including the option to quit Safari. You will likely have to force quit Safari. To do this, press Command + option + esc, select Safari, and press Force Quit.
Relaunch Safari
If you relaunch Safari, the page will reopen. To prevent this from happening, hold down the 'Shift' key while opening Safari. This will prevent windows from the last time Safari was running from reopening.
This will not work in all cases. The shift key must be held at the right time, and in some cases, even if done correctly, the window reappears. In these circumstances, after force quitting Safari, turn off Wi-Fi or disconnect Ethernet, depending on how you connect to the Internet. Then relaunch Safari normally. It will try to reload the malicious webpage, but without a connection, it won't be able to. Navigate away from that page by entering a different URL, i.e. www.apple.com, and trying to load it. Now you can reconnect to the Internet, and the page you entered will appear rather than the malicious one.
You Don’t Have a Virus and Don’t Pay Money to Remove
This is not a virus nor is it pop-up adware. Fortunately, it doesn’t affect anything but the browser, and it can be easily removed.
If it has opened a tab or window, then close the window by pressing COMMAND-W. A large box may pop open. Press the RETURN key which should dismiss the box and close the page.
If the above does not work then try the following:
1. Select Safari preferences. Click on the Security icon in the toolbar.
2. Locate the checkbox labeled, Enable JavaScript, and uncheck the box. Do not
close the preferences dialog.
3. Close the bad window or tab.
4. Re-check the JavaScript box and close the preferences dialog.
If the Preferences menuitem is inactive then quit or force quit Safari. Run Safari by holding down the SHIFT key while clicking Safari’s Dock icon. Select Safari preferences and click on the Privacy icon in the toolbar. At the top is a dropdown menu labeled, “Cookies and other website date.” Click on the Remove All Website Data… button.
Check your Downloads folder for anything you don’t recognize or remember downloading and delete it.