I am assuming that the pop up in question appears before you can got to any other sites. If that's the case skip to step 2.
1. If you can access other sites or have access to another computer download, install, and run Adware Medic
. Try the browser now. You can probably avoid step 2.
2. Close any open web browsers then do the following:
a. Disconnect completely from the Internet (turn off wi-fi and unplug the ethernet cable that leads to the computer).
b.Launch the web browser. The window that's trying to hijack your computer will try to appear and can't. Close the window or tab that is causing the problem.
c. Go to Safari Preferences > Advanced > Show Develop menu in menu bar: check that option then choose Empty Cache from the Develop menu.
d. Quit Safari, re-connect to wi-fi or ethernet, then re-launch Safari.
I don't think you will find it necessary to restart the Mac before relaunching Safari but it can't hurt.