How to keep a process running on the terminal after locking/logging out?
I believe that this has something to do with power savings settings. There is slider for "Turn display off after:" and by default "Prevent computer from sleeping automatically when the display is off" option is not selected. 

Maybe caffeinate can help (prevent the system from sleeping on behalf of a utility). 'man caffeinate' for more information.