1. Click in the menu bar and choose “Force Quit”.
In the window that opens up, select “Safari” and click “Force Quit.
2. Relaunch Safari holding the shift key down.
Additional steps if needed:
3. Turn off wifi and turn it back on.
Turn off Wifi. Click Wifi icon in the menu bar and select “Turn Wifi off”.
Visit another website.
You won’t have internet connection.
Turn on Wifi. Click Wifi icon in the menu bar and select “Turn Wifi on”.
Select your Network.
4. Click Safari in the Safari menu bar and choose “Clear History”.
Select an appropriate time frame.
5. If this doesn’t help, use Malwarebytes Anti-Malware for Mac to remove malware.
https://www.malwarebytes.org/antimalware/mac/
Download, install , open, and run it by clicking “Scan” button to remove adware.
Once done, quit Malwarebytes Anti-Malware for Mac.
Install guide: https://support.malwarebytes.com/docs/DOC-1817
The installer may ask you to allow it in System Preferences > Security & Privacy. Allow it.
Reselect your search engine, reset homepage and disable all extensions and test.
Restart your Mac.