Sometimes in Disk Utility when I try to unmount a volume I get this message:
Sometimes I'm not doing anything in those disks/volumes. Maybe it's something in the background still writing to them, but not me copying/deleting/changing files or folders.
Is there a way to force any "connection" to be "disconnected"?
I remember a few years ago I saw something online (can't find it now) where there was a way via the Terminal that would show some information about these "connections" and it would give us an "ID" or something like that and then we could force those connections to disconnect. It wouldn't always work though.
The command is, I believe, diskutil eject name_of_disk, but it probably won't work for a drive that generates the Finder message. You can get the name of all disks via diskutil list external.
You can use lsof to find out what's making the drive non-ejectable: sudo lsof /Volumes/name_of_disk. Most likely, you'll find that it's QuickLook, which has a nasty habit of staying open after being used. To fix that, you can either use QuickLook on a file on your internal drive, or use ps ax | grep QuickLook and then kill the QuickLook processes, but I wouldn't recommend this method.
If you look at the output of diskutil list external, you should see that volumes are given their own identifiers. None of my externals are set up like that, but my internal is:
Those are two volumes on one physical disk, but you can see that each is given a virtual identifier: disk3s1 and disk3s7. So you can easily eject just a specific volume.
Honestly, I don't have any idea. That looks to me like Spotlight is indexing the disk, which probably isn't a process you want to force quit. But I don't know for sure; the intricacies of what's going on in the Unix core of macOS is above my pay grade :).
So I guess in this case I would use something like this: diskutil eject disk3s1 (assuming that was the identifier, of course)
This was just a flash drive I connected just to see what content it would show using sudo lsof.
But I will see what I come up with when I experience that issue again.