Make the job succeed after stopping the server

I accessed my server using gitlab ci, the problem is that after I finish executing everything in the script, the job keeps running because I have to exit the server, but when I exit the server the job fails, I need to exit the server and make the job success, any fix for that?

This is my script:
stage: deploy
before_script:
- ‘which ssh-agent || ( apt-get update -y && apt-get install openssh-client git -y )’
- eval $(ssh-agent -s)
- echo "SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null - mkdir -p ~/.ssh - chmod 700 ~/.ssh - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' script: | ssh -tt ubuntu@{DEPLOY_SERVER}<<EOF
set -e
cd /var/www/apistaging
gem install bundler
git pull --no-edit
bundle install
RAILS_ENV=production bundle exec rake db:migrate
RAILS_ENV=production bundle exec rake assets:precompile
sudo service nginx restart
exit
EOF
only:
- develop