I then tried nohup <command> & detaching it supposedly from the terminal but it did not work either
I then found a program called screen
sudo apt-get install screen
To start an shell app just type
screen -Amd command
Once it's running, press Ctrl-a (control and a at the same time), then press d
to re-attach to it later, login with ssh and type
screen -r