Run the following commands to remove Nginx from MAC :
brew remove nginx
rm -f -R /opt/homebrew/Cellar/nginx
rm -f -R /opt/homebrew/etc/nginx
rm -f -R /opt/homebrew/var/homebrew/linked/nginx
rm -f -R /usr/local/nginx
rm -f /usr/local/sbin/nginx
rm -r /usr/local/var/run/nginx
rm -f -R /usr/local/etc/nginx
rm -r /usr/local/opt/nginx