Thank you very much guys!
Someone reffered me to this great article, and it solved the problem (or at least enabled me to turn off auto restart): https://williamlam.com/2013/02/enabl...r-failure.html
There are 2 options:
1. Boot into recovery (cmd + R) then open terminal and type: pmset autorestart 0 (1 is on).
2. Inside Ubuntu, open terminal and sign into root (sudo su -) then type: setpci -s 0:1f.0 0xa4.b=1 (there's another link in there for more information on this one).
It is still interesting why it autorestarted when the computer was initially turned off so I'll keep reading about it.
Bookmarks