Ventura – Terminal Won't Quit Via AppleScript

Hi @Nige_S,

See script below now properly formatted.

The script used to work prior to Ventura and he's used in conjunction with another script that deletes all the time machine snapshots.

Connect a Bluetooth Mouse Using a Macro

I am looking for an AppleScript that checks when the Terminal is no longer busy, wait five seconds and then quits app. Any help you can offer will be gratefully received.

set isBusy to true

repeat until isBusy is false
   tell application "Terminal"
      tell window 1
         set isBusy to busy as boolean --> Test if busy
      end tell
   end tell
   delay 1 --> Check every 2 seconds
end repeat

--display dialog "Terminal is No Longer Busy!"
delay 5
quit application "Terminal"