The system registry is (maybe?) written to the disk. Back on XP I noticed that if you made any changes to the registry then pulled the power, the changes would not be saved. I'm not quite sure about this one, just pointing it out.
Here's an excerpt from a document that Microsoft released.
• System session shutdown. This phase includes the pre-shutdown notification and shutdown notification subphases:
• Pre-shutdown notification. Windows serially shuts down all services that registered to receive pre-shutdown notifications. Ordered services—services that have set up the shutdown order of dependent services—are shut down before non-ordered services.
• Shutdown notification. All services that registered to receive shutdown notifications are shut down in parallel.
If all services have not exited after 20 seconds (in Windows Vista) or 12 seconds (in Windows 7 client operating systems), the system continues the shutdown. Processes and services that do not shut down in a timely manner are left running as the system shuts down.
• Kernel shutdown. The remainder of the system, such as all devices and drivers, are shut down during the kernel shutdown phase.
Basically what you're waiting on is each individual service to clean up and exit. Each service is given 12 seconds to exit before it's killed.
Half of the shutdown time is dedicated to shutting down system services. If you're really interesting in seeing what time is dedicated to what during your shutdown, Windows includes a tool for tracing shutdown time.
xbootmgr -trace shutdown -numRuns 3 -resultPath %systemdrive%\traces
-postBootDelay 180 -traceFlags base
And to make sense of the generated file (be sure to run in %systemdrive%\traces)
xperf -i trace.etl -o summary.xml -a shutdown
Sources: Update: Links from Microsoft Servers no longer work