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
There is a setting for this in the Terminal application. Unfortunately, it is relative to all Terminal windows, not only those launched via .command file.