Avoid automatic shutdown
Make sure your power adapter is connected to the Mac while you are sleeping.
In the Power Adapter section in Energy Saver, make the "computer sleep" -> "never".
You don't want your screen is on when you are in bed right? So make "Display sleep" -> some minutes.
Uncheck "Put the hard disk(s) to sleep when possible" and "Restart automatically if the computer freezes".


That should work!