Force quit Terminal.app using Apple Script Editor
5,275
It looks like I found the answer to my owned question
tell application "Terminal"
quit
tell application "System Events"
keystroke return
end tell
end tell
Related videos on Youtube
![code-8](https://i.stack.imgur.com/FIrOY.png?s=256&g=1)
Author by
code-8
Updated on September 18, 2022Comments
-
code-8 almost 2 years
I'm trying to force quit my Terminal.app using Apple Script Editor
tell application "Terminal" quit end tell tell application "System Events" key code 53 end tell
It does not seem to work. How would one go about and did that ?
-
user3439894 over 3 yearsA simple
do shell script "pkill -9 -x Terminal"
will do the job without then need for System Events. -
CJK over 3 years@user3439894 Ugh, there are a few small but irksome niggles in this answer that I kind of find embarrassing to be reading two years later, wondering why the hell did I used to indent code blocks from line 1. I'm also appalled I headed straight for
SIGKILL
, which is kinda overdoing it and not recommended to be sent by the user. Most force quits areSIGTERM
. But I must not have known aboutpkill
back then, as I never usekill
now aspkill
makes it easier, and also has more functionality along withpgrep
. So, what drew you back here, then? Were you trying to quit Terminal? -
user3439894 over 3 yearsCJK, It got bumped to the top of the cue by Community, so I took a look at it, that's all. :)
-
CJK over 3 years@user3439894 Ah, ok. Thanks for telling me. In that case, I shall update the answer as there's enough bad AppleScript and Shell Script examples out there, I should do my best not to add to that if it's possibly getting a wider/renewed exposure.