WIndows 11 has an annoying habit of rebooting automatically especially after doing some updates. I found a solution to stop it.
What you need to do is edit registry, so type regedit, then go to HKEY_LOCAL_MACHINE then SOFTWARE then Microsoft and then Windows.
Right click on Windows folder and choose New -> Key and call it Windows Update

Do the same and under Windows Update create a new key called AU
Then right click on AU and select New -> DWORD 32 bit and call it NoAutoRebootWithLoggedOnUser

Double click it and …

and change the value to 1

Click OK – job done.