If you want to execute a long-running task on a machine, use screen. It even works on a Mac.

Start by typing screen:

You’ll see this:

Now start your long-running task:

Pressing ctrl a + d will return you to your previous session.

screen -r will return you to the session again: