I had this issue with my 2013 iMac. It started turning off randomly at the end of 2017 and only happened once every couple of weeks. It progressively got worse over months to the point it shuts off daily. I tried the PRAM reset and even reinstalling the OS, but it continued. I bought a new grounded power strip and that didn’t help. I was fed up so I got Apple involved. Apple Engineer’s spent hours trying to troubleshoot remotely and found nothing. They checked my log files, and even when the iMac shut off in the middle of the test, it showed NOTHING. They booted into safe mode, and it still randomly shut off. Because of this, they suggested it was probably defective hardware. I brought it into the Apple store 3 times. The first time they replaced the RAM and said it passed their diagnostic test. I brought it home and it continued to happen. I went back to the store and they changed the battery supply and it passed their diagnostics. But it continued to happen at home. The final time I brought it in they replaced the logic board and the issue seemed to be resolved. However, they put the wrong board in my iMac so they ended up giving me a new one, so I am not completely sure. The new iMac Has had no issue for the past 6 months I’ve had it. As someone who has troubleshooted a lot of tech issues on my own, this experience was BY FAR the most frustrating I’ve experienced. I honestly couldn’t believe that Apple’s own Engineer’s had no viable diagnostics to identify the problem, hardware or software. Something was obviously failing. And by the way, I paid out of pocket for each repair. At the time, I searched for solutions online and found people going through similar situations with random shut downs, and Apple wasn’t able to diagnose the problem. If your situation is hardware related, it seems different replacements work for different people, so it could be a process of trial and error. I can only hope it’s as simple as a PRAM reset for you. Good luck!
[automerge]1569996813[/automerge]
I forgot to include that the symptoms were the same as yours. When it shut down randomly, I needed to unplug it for a few seconds or else it wouldn’t power back on.