Use the disown shell builtin to exit the shell but continue running already back grounded jobs. The syntax changes from shell to shell.
zsh
disown [ job ... ]
bash
disown [-ar] [-h] [jobspec ...]
Example:
foo &
disown %1
exit
Relevant commands:
* find the parent pid
ps xao pid,ppid,comm | grep foo
* get information on a process
ps aux | grep NNNN
Ref:-
* https://www.slashroot.in/disown-command-linux-explained-example-usage - goes into the details; good explanation with relevant screenshots; has some typos;
* relevant section in zsh documentation: http://zsh.sourceforge.net/Doc/Release/Shell-Builtin-Commands.html -> search for disown
* relevant section in bash documentation: http://manpages.ubuntu.com/manpages/bionic/man7/bash-builtins.7.html -> search for disown -> go to the second hit
Note:- To attach a disowned job, the instructions in https://unix.stackexchange.com/questions/31824/how-do-i-attach-a-terminal-to-a-detached-process might be helpful. But I have not tried them.
tags | continue running the jobs in the background, detach