If you are using screen, you can detach your session by typing
Ctrl+A D (detach)
.
All your screens remain active and can later be resumed. You do this by typing
screen -r
.
If there is only one session to be resumed, it will be resumed automatically; otherwise you need to specify which screen session you want to resume by typing
screen -r [pid].[tty].[host]
.
There is one more catch: sometimes you get disconnected. It is possible that your session will stay attached. If a session is attached, you can’t attach to it unless you first detach it. But it’s not difficult: just type
screen -d -r [pid].[tty].[host]
.
-d is for detach, -r is for resume.