The other answers are great, but to give some greater detail: computers have a system known as [ACPI](https://en.wikipedia.org/wiki/Advanced_Configuration_and_Power_Interface) that allows the Operating System to directly control the machine’s power state. ACPI works at the firmware level, which is why it’s able to have such intimate control over the hardware. When you give your OS a command like “shutdown” or “reboot” it sends a command through the ACPI in order to fulfill the request.
ACPI is also the reason why your operating system is able to put the computer to sleep when it’s been idle for too long or because you close the lid.
Latest Answers