I was wondering if there are other solutions to this problem. What happens is like the OP stated; sometimes (randomly) the computer tells me the hard drive wasn't ejected properly when I wake it up from sleep. I did not disconnect the drive, just put the computer to sleep.
The solution proposed above just unmounts the hard drive, but I want it to stay mounted all the time.
The drive does mount again when you wake up the computer, the only real 'issue' is that notification that has to be clicked away every time. To my knowledge, the hard drive is not damaged by this issue (or is it?) and it wouldn't happen if the computer was still using the hard drive. I have a backup BTW.
Edit: More info here:
https://forums.macrumors.com/threads/disk-not-ejected-properly.2097413/