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
Short of having to use the AppleScript solutions above, this is the only shell script solution that worked (exit
didn't), even if abruptly, for me (tested in OS X 10.9):
...
echo "$l" done
done
killall Terminal
Of course this will kill all running Terminal instances, so if you were working on a Terminal window before launching the script, it will be terminated as well. Luckily, relaunching Terminal gets you to a "Restored" state but, nevertheless, this must be considered only for edge cases and not as a clean solution.