If you download/run (nothing to install) Process Monitor
, you will get a feel for how many things are happening each second on your computer. Thousands of things are happening each second while the computer is running or shutting down.
When you shut down the operating system, it sends that shut down info to applications and services that are running. Each service or app should do what it was programmed to do once it gets that shut down signal. Some apps and services write data to files and the close the file before exiting RAM. Other apps/services don't need to save any data, they just exit RAM. The Window Operating System is just a bunch of apps and services. As a whole, Windows saves data to a lot of files during a shut down.
From what I've seen, the hard drive controller parks the heads if there is a power loss or if a shock sensor tells the controller to park the heads. But some drives auto-park the heads when the heads are not needed to read/write data. You can find more than you would care to read about Western Digital drives auto-parking
. Other drive makers do this too.