[Editor: Please see the comments; this is probably NOT the best way to do this!! Kill is fairly abrupt, and will end ALL terminal sessions. The comments have some alternative.]
This is one I've been trying to figure out for quite some time and finally managed to figure out so I thought that I'd share it with you.
I wanted to run a shell script from the GUI and have the Terminal close itself down at the end of the script. The only way I knew to do this was to use a modified version of the Dock Restart script from elsewhere on this site. i.e.
TERM=`ps aucx| grep Terminal | cut -d ' ' -f 4-5`
kill $TERM
but this would result in a "Application unexpectedly quit" error message. If you change the line "kill $TERM" to "kill -9 $TERM" the error message no longer appears. Simply add those lines at the end of your script to make the Terminal vanish when the script is complete.
So now to make a script executable from the GUI.
1) Type the script in your favourite plaintext editor, include the above script at the end.
2) from the terminal run "chmod +x Text.file" (Where Text.file is your files name)
3) In the Finder do a 'get info' on your text file and change the Application to Terminal.
4) Double click the file and voila a script that runs itself and then quits the terminal with no error.
I hope this helps a few people.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20010702041812535