By default, windows is configured to install windows updates automatically, which can mean that your computer will be rebooted at an inconvenient time.
To change when and how windows update are applied:
Windows 7:
Control panel > System and Security > Windows Update > Turn automatic updating on or off


Windows 10:
Disabling automatic updates using local group policy
On Windows 10, you can stop automatic updates using the registry.
Steps:
1. Open run command (windows key + R key shortcut).
2. Type gpedit.msc > click OK.
3. Browse to:
Computer Configuration > Administrative Templates > Windows Components > Windows Update
4. Double-click the Configure Automatic Updates policy.
5. Check the Enabled option to turn on the policy.
Under the 'Options' section, you'll find a number of options to configure automatic updates, including:
- Notify for download and auto install.
- Auto download and notify for install.
- Auto download and schedule the install.
- Allow local admin to choose setting.
Select the option that best fits your preference,
but option 2 - Notify for download and auto install is the closest to permanently disable automatic updates.
6. Click Apply and OK, and that's it.

Note: if you want to disable windows altogether, check 'Disabled' in Configure Automatic Updates windows. However, this is NOT a good idea.
For more information, see here.