
System/Volumes/Data/Volumes/TimeMachine: sudo mdutil -Ei off "/Volumes/TimeMachine"

Secondly I tried stopping the indexing with the terminal by entering the following and got the also following result.

Then I tried stopping spotlight from indexing them, first by adding the volume to settings->spotlight->privacy but it stated that I can't add a Volume that is used for Time Machine Backups. I tried force quitting them while the eject process was going on but that didn't help. I figured out that the processes "mds" and "mds_store" keep the hard drive from being ejected safely. I tried completely removing the volume from TimeMachine and stopping automated backups but that didn't help.

It always states that some program is still using it. Now I have the problem that I can't eject this hard drive without shutting down the Mac. I'm running MacOS 12.1 on my 14" MacBook Pro and I currently use an external hard drive, that is connected to my dock as an TimeMachine Backup (so that it backups every hour or so while I'm working at my desk).
