You could try a start in Safe mode:
• Try safe mode if your Mac doesn't finish starting up - Apple Support
That may allow further troubleshooting.
Also, sometimes there may be a hardware issue that an SMC reset may help with
depending on the cause:
• Resetting the System Management Controller (SMC) on your Mac - Apple Support
You may be able to try the Hardware test to see what appears in results:
• Using Apple Hardware Test - Apple Support
Other options include scheduling an appointment with an Apple Store genius or an
authorized Apple service provider to have the unit inspected, diagnostic tests, etc.
There may be system software or hardware issues, so to troubleshoot to attempt
to see what is the cause, may take time. If you have a backup in Time Machine &
end up using OS X Recovery to see about using OS X Utilities, Disk Utility or
other functions, be aware this can do more advanced features; it may not need.
Because this issue appears as a symptom in Safari, that makes it most curious.
• Stop pop-up ads and adware in Safari - Apple Support
http://etrecheck.com/ http://www.adwaremedic.com/index.php
There may be an odd extension in Safari that may relate to some adware or other
items, so that is another matter to consider; an Etrecheck report may tell you if
some of the candidates are in there; but maybe not. I don't use Safari primarily
so my other two browsers work a little differently.
Good luck & happy computing! 🙂