How to prevent the application launched in Terminal from undesirably exiting?
The "standard" way of accomplishing what you want to accomplish (on OS X as well as on Linux, FreeBSD or other systems) is to use the command nohup:

nohup program &amp;


This will start program, which will run in the background relative to the shell because of the &amp; - and will ignore hangup signals due to the nohup command.

This way the program will continue running even though you close the shell. It doesn't matter if you're closing the shell because you're closing Terminal.app, or you're closing the shell because you are disconnecting from a ssh connection to the computer, or similar.