Hi and Welcome. My Name is ***** ***** I look forward to assisting you today with your question.
That is a SCAM message. These kind of scam pages opens from pop up ads, adult websites etc. These are not harmful to your Mac. When you get them, just disconnect your WiFi/internet connection, close and reopen Firefox/Safari and close that page. You can't prevent your Mac from getting these pages. Internet is full of these kind of fake and scam things. When you get them, just clear your browser.
If you are unable to close that page, then follow the steps below;
Close Firefox. If you are unable to close it, then press Command, Option and Esc keys and this will bring Force Quit. Select Firefox and click Force Quit. Then hold down Shift key and open Firefox. This will prevent the page from loading. (If not, force quit Firefox again, then turn off WiFi/Internet and open Firefox)
Then click on Firefox menu at top left and select Preferences. Click on Privacy in left column. Click clear your recent history and clear all. That should remove it.
(For Safari, click on Safari menu and select Clear History and Website Data)
Also, download, install and scan your Mac with Antimalware application --> https://www.malwarebytes.com/antimalware/mac/
Malwarebytes Antimalware will find and remove all malwares/adwares from your Mac if anything is installed.
Note : It is not necessary to clean up your entire Mac. These scam pages can only affect your browsers and it can be easily cleared.
If you have any difficulty on following the steps above, please let me know and I will continue to help you