> That should do it.
> > -- quit the applications safely, allowing them to cleanup
> > tell application "Foo" to quit
[quoted text clipped - 4 lines]
> You just wrote a race condition. Why not wait until the quit
> command finishes, instead?
Is this a trick question? If you wait "until the quit command
finishes," you're never going to give up and decide it's not going to
quit. The way it works is, you give 'em plenty of opportunity to quit
cleanly. If they don't, you make them quit.
Any app that doesn't respond _for_an_entire_minute_ when you tell it to
quit is hung, almost by definition. Or else it is waiting, like stupid
iChat, for user permission to quit, wihch it's never going to get
because there's nobody in front of the terminal.
> > -- quit any apps that didn't quit successfully the UNIX way
> > -- kill any hangers-on with extreme prejudice
>
> Aaaaahrgh! Why not just send 'em a TERM signal, and make sure
> they really died? Get rid of all the "just in case" wait
> statements, and test for what should happen?
Well, what are you going to do if it didn't happen? Tell it again to
do what it didn't do the last time you told it? How would that help?
The nice thing about the killall is that it's a no-op if the app did
quit properly (asuming the names are sufficiently unique). It saves
the complicated if statements and whatnot. I was trying to keep the
script simple enough so that, you know, the original poster could adapt
it to his needs without having to understand _too_ much AppleScript.
That's the same reason I didn't use a list with all the app names in it
and a loop to go through them.

Signature
Jerry Kindall, Seattle, WA <http://www.jerrykindall.com/>
Send only plain text messages under 32K to the Reply-To address.
This mailbox is filtered aggressively to thwart spam and viruses.
Rin - 09 Feb 2005 14:40 GMT
Wow, this is great, thanks. Two problems -- we're running OS 9, and I
have no clue how to use AppleScript (I have a book, though, and I can
write databases, so I'll probably get it). Jerry, is this going to work
with OS 9?
I'm sure you'll hear from me again, with whining when I don't get it
right.
> > > -- quit the applications safely, allowing them to cleanup
> > > tell application "Foo" to quit
[quoted text clipped - 38 lines]
> Send only plain text messages under 32K to the Reply-To address.
> This mailbox is filtered aggressively to thwart spam and viruses.
Jerry Kindall - 09 Feb 2005 17:14 GMT
> Wow, this is great, thanks. Two problems -- we're running OS 9, and I
> have no clue how to use AppleScript (I have a book, though, and I can
> write databases, so I'll probably get it). Jerry, is this going to work
> with OS 9?
Well, you can't use the lines with the "kill" commands, which makes
Dave's critique of it moot. Those are UNIX shell commands and they
only work on Mac OS X. But the tell application "Foo" to quit stuff
will work. It's just that if an application is hung, or wants user
input before it quits, it won't be quit.

Signature
Jerry Kindall, Seattle, WA <http://www.jerrykindall.com/>
Send only plain text messages under 32K to the Reply-To address.
This mailbox is filtered aggressively to thwart spam and viruses.
Rin - 10 Feb 2005 14:45 GMT
Thanks for the help!
> > Wow, this is great, thanks. Two problems -- we're running OS 9, and I
> > have no clue how to use AppleScript (I have a book, though, and I can
[quoted text clipped - 12 lines]
> Send only plain text messages under 32K to the Reply-To address.
> This mailbox is filtered aggressively to thwart spam and viruses.