Thank you.
I actually tried something like that just now (suggested by ChatGPT) and it worked.
So, the final script is now:
#!/bin/bash
VOLUME_PATH="$KMVAR_Local__volumeDiskName"
diskutil unmount force "$VOLUME_PATH"
while mount | grep -q "$VOLUME_PATH"; do
sleep 5
done
osascript -e 'display notification "'"$VOLUME_PATH"'" with title "✅ Unmounted Successfully!"'
Would it be ok to leave force? Or just diskutil unmount "MyDisk"?
This disk is kind of a "backup" and I will usually just run this macro once I have all files safe somewhere else.
The manual page for diskutil notes (unsurprisingly) that the force option is “less kind to any open files”, so why not see how you get on without that option. I do not think you will need it.