Normally, when SSH closes the processes get sent a SIGHUP signal (actually two in short order) and then do with that what they will. The normal reaction is to stop.
If you don't write your program to trap and process SIGHUP you can use
nohup to protect a single process or, as mentioned already,
tmux or
screen. I prefer
tmux of the two and now use it almost exclusively over
screen even though I'd been using the latter for many years.
systemd is said to break all of that, starting last year. Though some distros are also said to have deployed a work-around to keep the session behavior as expected. Check with your specific distro to see the exact situation on your hands.