Windows knows better then you when to restart your computer. And Windows 10 is the most qualified in such knowledge. That’s why in some scenarios you may lost 40+ tabs open in your browser and a lot of programs running, when your Windows decided that it must be restarted right now.
There are many approaches to preventing Windows 10 from auto-restarting itself:
- Step 2 in this Super User answer
- Another one (quick and easy, Registry manipulation): here + here
- Some other one (long and detailed), in case the first one doesn’t work
However, the solution that worked for me is “Disable Automatic Windows 10 Restarts” script at GitHub.