Let me preface this by saying that I am in no way a tech person. I just followed other people's advice and somehow it eventually worked for me. I'm sure I didn't do it the easiest way or the fastest way, but I was trying anything I thought might help.
1) First I tried overriding Safari with a new version but then realized that it was incompatible with Lion, so I upgraded to Yosemite. Didn't help.
2) I then opened Safari (same problem was happening) and did a force quit. There are a number of ways to do that but I chose to click on the apple in the top-left corner, go down to force quit, and then select Safari. Then I went in to Library > Safari and deleted the "LastSession.plist" and then emptied my trash so that it would be totally off my computer. Then I reopened Safari holding the shift key. When it opened, a box came up basically asking if I wanted to restore my last session. Read it carefully and choose the option that will start a new session instead of reopening your old work.
I have no idea if the fact that I upgraded my Safari and operating system helped or changed anything. You may be able to do everything in Step 2 and get the same result....but that's just how it all worked for me.
Hopefully it helps. But I know this particular adware popup i a real bi-atch because it basically totally disables Safari.