you started a process on the foreground and need to put it in a background so you can exit the ssh shell, then you can run the following:
press [CTRL]+[Z]
bg
disown -h
exit
If you need to start a new process and put in background, you can use the nohup command as follow:
nohup ./loop.sh &