Using nginx command line and passing -s quit will terminate NGINX once all connections have been completed.
nginx
-s quit
sudo nginx -s quit
More on NGINX signals: Controlling NGINX