How I can make sure my code is keep running?
A simple way would be install a GUI app. A good one is KeepingYouAwake. This app is a GUI front-end to caffeinate command. It's very simple to install and configure, and keeps your computer from sleeping.

You can install it via Homebrew by running:

brew cask install keepingyouawake

If you don't have Homebrew installed, you can follow the instructions to install it on it's homepage:

https://brew.sh