script hangs at "tell Safari to quit" bcs multiple tags open querry

I am trying to write a script to automatically close Safari (or other applications) under specified conditions.

However, in the line telling Safari to quit, the script hangs, because Safari opens a dialog box saying “There
are multiple tabs open, are you sure you want to quit? Cancel / Quit”

Even if I knew how to script the keystroke “enter” to activate the Quit button, I don’t know how to make this
happen, because the script never reads beyond the “quit” command. How do I write the script so that it will
finish the quit function once the dialog box arises? (Alternately, can I get the script to abort the “quit” function
if the dialog box appears, but move on to execute the rest of the script?)

My script is copied below. Thanks very much for any guidance!
Chris

{repeat
set t to (time of (current date))
if t is in [7200, 10800] then exit repeat
if t is greater than 72000 then
tell application “System Events”
if exists process “Safari” then
tell application “Safari”
quit
end tell
end if
if exists process “Firefox” then
tell application “Firefox”
quit
end tell
end if
end tell
end if
delay 120
end repeat}

This format is standard in many apps:

tell application "Safari" to quit without saving