Hello all, here is my story and so far, my solution to the Imac shutdown saga.
I also have the iMac (27-inch, Late 2012)
Processor 2.9 Ghz Intel Core i5
Memory GB 1600 Mhz DDR3
Graphics NVIDIA GeForce GTX 660M 512 MB
1TB Fusion Drive
Purchased computer 01/2013. As of 07/11/2016, out of the blue like so many others, my computer started shutting down randomly. I ran the AHT test and the error code stated that my hard drive was failing. I took my computer to the Genius bar and after they tested it, they came up with the same issue. They kept it for a few days and replaced my hard drive ($160 including tax and labor). For the next week, my computer was like new again. However, on 07/25, the issue returned. After reading these posts, I was reluctant to take it back to the apple store because it is a pain in the neck to lug this thing back and forth. I tried everything I could to avoid that trip. However, just for the heck of it, I decided to download the macs fan control from the previous post: http://www.crystalidea.com/macs-fan-control. The main fan RPM minimum is: 1200 - 2640 (max). I set it to 1500 and watched it. I also read in one of these post that if the CPU goes above 65, the the computer would shut down. What I have noticed is that ever since I installed the fan control, and started to notice which programs cause the temp to rise, my computer has not shut down and the back of my computer has been cooler.
Now I am not sure if this solution will work for everyone, but I must say, so far, it has worked for me. I noticed that chrome and safari used alot of memory, so i switched to firefox. Once again, so far as of today, I haven't any shutdowns in two days. Of course, time will tell because this issue seems to rear its ugly head whenever it wants to. I will keep you posted as to how long I go without a shutdown. I am keeping an eye on the fan control temps as well as the activity monitor that is built into the Imac.