I have a repeatedly run into this problem. On the one hand we could say, "always remember to eject your external drives before removing them". However, it's a matter of fact that I will forget, at least sometimes.
On macOS Mojave, this results in a complete system breakdown. What happens is that the disk is still shown as connected to the computer, but it's not actually there.
Any attempt to eject the disk, either with the UI, Disk Utility or commands such as
umount -f /Volumes/TheDrive/ fail (hang).
Also, any processes that need to be aware of /Volumes/* will also hang, for example
fuser /Volumes/TheDrive hangs, and eventually the Finder hangs. This means that most software eventually hangs.
Attempting to reboot the system hangs.
The Finder hangs, and trying to restart the Finder hangs.
The system becomes unusable and unrecoverable and can only be fixed by holding down the power button to kill the electricity.
I am looking for a way to recover the system when it is in this state. Probably, I need to kill certain processes and somehow eject/unmount the (not-connected) external drive that is the culprit.
Research: This is a different problem, with no answer Eject / unmount ghost external disk on macOS
This does not work https://www.mactrast.com/2012/07/quick-tip-force-a-disk-to-unmount-in-os-x/
This discussion does not address my issue https://discussions.apple.com/thread/3619092
(and many other dead ends...)
rm -rf /Volumes/TheDrive hangs as well.