For example lets say I was in the middle of running a script I want to be able to keep the ssh session alive so I continue where I left off.
You can use the screen (or tmux, but I'm not familiar with it) terminal multiplexer. First install it with
sudo apt install screen. Then just start it with
screen. You will get a normal terminal with a command line. You can start programs there as usual but you are able to detach from the screen terminal with Ctrla+d. This will leave the screen terminal but a program that was started in screen is still running. If you want to reattach to the running program execute:
rpi ~$ screen -r
Within screen you can get help with Ctrla+? or look at