Stop the mosquitto (MQTT) broker from listening to a port using the command line
If you don't know the PID, than you can use "pkill" instead of "kill" in linux. Command: "pkill mosquitto"
mosquitto starts to be a service.
sudo vi /etc/mosquitto/mosquitto.conf #more detail in `man mosquitto.conf`
sudo vi /etc/mosquitto/conf.d/custom.conf #add or change listening port as your need
sudo service mosquitto restart
You don't say which OS you are using, but assuming it's Linux and you have mosquitto running in the background, you just use the kill command.
Use ps to find the pid of the currently running mosquitto instance then kill the pid.