Interrupt or break a running script?

The following script creates tabs in Safari. In practice, it would be scripted to open web pages into tabs from a list of URLS.

I’m looking for a way to interrupt it from the keyboard without having to Force Quit Safari itself

tell application “Safari”
activate
make new document with properties {name:“Tabs”}
repeat with i from 1 to 10
set theURL to “About:blank”
open location theURL in window “Tabs”
my new_tab()
delay 1
end repeat
end tell

on new_tab()
tell application “Safari”
activate window “Tabs”
tell application “System Events”
tell process “Safari”
click menu item “New Tab” of menu “File” of menu bar 1
end tell
end tell

end tell

end new_tab

This may be done if you rewrite this script in other form - as stay-open application, save it, run it, give all requested by the system permissions on first start. Then quit it and use. As the applet has menu item QUIT, you can interrupt the process, or you can assign one shortcut to menu item QUIT and use it too:


on initialize()
	tell application "Safari"
		activate
		make new document with properties {name:"Tabs"}
	end tell
end initialize

on run {}
	initialize()
end run

on idle {}
	tell application "Safari"
		activate
		set theURL to "About:blank"
		open location theURL in window "Tabs"
		my new_tab()
	end tell
	delay 1
end idle

on new_tab()
	tell application "Safari"
		activate window "Tabs"
		tell application "System Events"
			tell process "Safari"
				click menu item "New Tab" of menu "File" of menu bar 1
			end tell
		end tell
		
	end tell
end new_tab

on quit {}
	continue quit
end quit