--This script will limit the number of Safari windows you can open
tell application "Safari"
repeat
if the count of every document is greater than [number] then
repeat until the count of every document is [number]
close the front document
end repeat
end if
end repeat
end tell