As the error message indicates, you can't unmount or eject the external hard drive because it is still in use. Therefore, you should identify which process is accessing the external hard drive, close such process, and then try to unmount the drive again.
First Aid is a powerful feature provided by macOS Disk Utility to check and repair hard drives. Unexpectedly, you received the unable to unmount volume for repair error when you attempt to repair the Time Machine backup drive, and can't eject the external hard drive on Mac because it is currently in use by "com.apple.dock.extra" as the message says.
Dock Extras are programs that reside in the macOS. When you control-click the icon in Mac Dock, instead of opening a document, folder, or application, it will display a menu or show information. According to the error message, it could be the running process in Mac Dock that access the drive resulting in the issue. Therefore, close suspicious applications from the Dock.
In addition, if the Time Machine is in the process of updating the backup, it could also prevent you from unmounting and ejecting the drive. You'd better wait for the process to complete.
Then, quit other apps which are using the drive, you can click the Apple Menu and choose Force Quit to check running applications on your Mac.
In case there is data loss on the Time Machine backup drive, try iBoysoft Data Recovery for Mac to recover.