I recently ran into a problem with macOS High Sierra in which I could not eject a drive because the system thought it was being shared.
I had previously shared it, true, but the client no longer had the device mounted.
smbd was confused and rejecting the unmount.
diskutil to try an unmount didn't work. The OS was
trying desperately to protect me from myself.
Eventually I found the solution, which was to use the
keyword in addition to the unmount:
diskutil unmountDisk force /Volumes/Disk_Name