Applescript to quit all active browser processes
tell application "System Events"
    set ProcessList to name of every process
    if "Safari" is in ProcessList then
        tell application "Safari"
            quit
        end tell
    end if
end tell


Repeat as needed