What exactly goes on when my computer is shut down? Not the "Shut down" button in the Start menu, but instead how the command (maybe machine code or something similar) is issued on a lower-than-OS level, or the operation that actually turns off the computer's power.
ACPI (Advanced Configuration and Power Interface) is the name of the technology that is used. Effectively, the processor can actually talk to the power supply itself and give it a direct instruction to power off certain power circuits. Other circuits may be kept open depending on configuration to support such things as wake on LAN.
This is actually part of how just about any power state works, though more complex states like Sleep or Suspend have to also be supported by other hardware. For more information, you may want to read up on ACPI power states. The ACPI Wikipedia article is a very good in-depth read on the topic.
Here is another article that may shed some light on tie shutdown sequence. It is a little simplistic, but it might shed some light...