When you close a shell out, it sends SIGHUP signal to all jobs that it's spawned. By default, SIGHUP will terminate any process.
If you know you need to 'keep it running' when you spawn the process, you can use
nohup to spawn your process. As a side effect, it will redirect stdout and stderr to a file nohup.out if these streams were pointing to the terminal. You may want to redirect these yourself if you don't want this file.
You can also run it using
setsid, which creates a new process group. Your shell will no longer send SIGHUP to it since it's not in the shell's process group.
If you've already started your program, and you happen to be running bash or zsh (very likely on Linux), you can use
Either run the command with
& to force background, or run it normally type Ctrl-Z to suspend it, then
bg %1 (assuming it's job #1) to take it out of suspension and run it as a background process. Then you type
disown %1 to make bash/zsh forget about it.
disown is my usual method, I don't need to remember to mess with output streams like