Just in case it helps anybody else, I've been having this same issue for months. My computer is a late 2012 iMac 27" running OSX 10.13.1 and it will go completely black and be unresponsive to any inputs, including the power button, until the cord is unplugged for at least 10-15 seconds and put back in.
I spent a couple months testing it and found that it never has the issue when I have only the thunderbolt plugged in. I would keep an external monitor plugged into one of them for a couple weeks and the error would never occur. Then, I started testing the USB ports individually and one by one 3 out of the 4 have had the issue. I'm now testing the 4th and I expect it will occur there eventually. USB port #3 took a few weeks to fail, which was surprising, but finally did it tonight after an update. Thankfully it didn't seem to happen during the update at least.
It drives me nuts, but I suppose I could perhaps figure out a workaround by having a thunderbolt to USB adapter. I'm currently testing the last USB with a wired apple keyboard, and have tested the other ports with a bluetooth mouse/keyboard dongle.
I've looked elsewhere for any info on this and had seen people saying that it had something to do with USB, which is what led me to this attempt at troubleshooting. I'm skeptical that apple would be able to help much from what I've read and the experience I had with support already. And since I bought this machine used and it's 5 years old, it's likely not worth dropping a significant chunk of change on a repair if I can do the thunderbolt to USB workaround.
Ugh, so annoying. Anyway, perhaps that'll help someone else with diagnosing this issue.