How do I repair my HDD when Disk Utility won't recognise it needs repairing?
I would probably do a reinstall of Mac OS X Yosemite. Doing so will not delete your personal files, but will reinstall the files that the operating system requires. It sounds like there's either a Mac OS X operation or some other third party operation hanging in the background while it's tying to shut down.

If that doesn't work, there are some third party HD diagnostics tools out there. I'd recommend checking one of those out. Additionally, when you take it to the Genius Bar, they'd most likely run an Apple Hardware Diagnostics test.

If it shows anything here, and if the computer is under warranty, I'd make a free appt at the Apple Genius Bar and get the hard drive replaced.

Additionally, as a last-case scenario, you can completely erase the HD and then completely reinstall the OS X. If it doesn't hang after that and you don't see any more errors with the HD, then it has been isolated to a software issue.