Haven’t tried it myself but I think if I would want to achieve the unmounting just before shutdown I would try it with a systemd-service and this suggestion: https://unix.stackexchange.com/questions/39226/how-to-run-a-script-with-systemd-right-before-shutdown
In ExecStop=... you would put your umount command
If that HDD is wired to the SATA bus, and not an external USB disk, is it included in /etc/fstab so that it is automatically mounted/unmounted as a system disk?
Sata yes. I think it is included but i can give it a try and see if i can clean it up.
Easy to check, e.g.:
bruno@LT-B:~> lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 232,9G 0 disk
├─sda1 8:1 0 200M 0 part /boot/efi
├─sda2 8:2 0 175,8G 0 part /home
├─sda3 8:3 0 25G 0 part /
├─sda4 8:4 0 8G 0 part [SWAP]
└─sda5 8:5 0 15,9G 0 part /run/media/bruno/Leap16.0
sr0 11:0 1 1024M 0 rom
bruno@LT-B:~>
Partitions or disks in fstab have a mountpoint defined in /etc/fstab but partitions or disks mounted by a user via gvfs (like my sda5 above) have a mount point like /run/media/<username>/<label>
and since your trouble points to gvfs I think that is the case for your problem disk too.
I found a way to unmount the disk when it was idling. That solved the problem entirely. Thanks, the problem was less complicated than thought, it was just a HDD thinking it was busy.
So for others looking here in the future, check in fstab and add argument of your choice https://wiki.archlinux.org/title/Fstab#Automatic_unmount.