Why does my Macbook Pro try to shut down when I leave it unattended?
Try going to System Preferences and choosing Security &amp; Privacy.  When that application window opens, choose "General" tab and then look to the lower right corner and click on "Advanced".  Uncheck "Log out after _ _ minutes of inactivity.

Not sure but this might be the cause.

Good luck