Safari playing a youtube video in the background
You might want to try this solution from Apple's own forum (be sure to back-up your Bookmarks first):


  Open a Finder window. Select your Home folder in the Sidebar on the
  left. Now open the Library folder then the Safari folder.
  
  Move the LastSession.plist and the Downloads.plist files from the
  Safari folder to the Trash.
  
  Restart your Mac.


It also could be an extension messing up with Safari.