Which is why LPZ and others have questioned your choice of tools. Xcode and Applescript vs. TexShop or even emacs/Aquamacs.
You are trying to adapt a Phillips screwdriver to turn a flathead screw. Sure, you can probably get it to work with enough effort, but it will never be as ideal as using the right tool in the first place.
B
I do understand that. Therefore I've tried to be as short as possible such that I could solve the little problem that I have. Which originally was, quit Terminal when command line has executed. Or in other words, find a sandpaper to file my Phillips screwdriver such that it looks like a flathead screwdriver and works to its purpose.