In my shell script, my last lines are:
... echo \"$l\" done done exit
I have Terminal preference set to \"When the shell exits: Close the wind
I'm using the following command in my script
quit -n terminal
Of course you have to have the terminal set to never prompt before closing.