I usually run dfx start in the foreground in a dedicated terminal, on Ubuntu Linux. When I stop the process and try to start it up again relatively soon after stopping (sometimes multiple seconds) I often get this error: Address in use (os error 98).
It would be nice if it could clean itself up more quickly, just for a better developer experience.
Try running dfx start and then immediately cancel the process with Ctrl+c or the equivalent on your machine (I’m using Ubuntu). After that try dfx stop. I think that’s often when dfx stop can’t stop all processes.
That being said, now dfx gives me the ids of the processes that it couldn’t stop. So I just do a sudo kill -9 process_id and I believe that fixes it every time and allows me to dodfx start again.