This question already has an answer here:
Late 2015 iMac is rebooting on its own. Only Finder running, OSX 10.11.6. (2) 8GB RAM sticks. Got to catch it in the act today.
After reboot I find kernel: Previous shutdown cause: -128
That doesn't appear to correspond to anything useful in the old MacOS error codes documentation from 1998:
-128 userCanceledErr User canceled an operation
The is a refurb unit, hoping it doesn't need to go back for another refurbishment.