Compwhiz,
It's the pause during drain (from opening the lid) that triggers the transmission to shift into spin. If you notice when you don't open the lid during drain, there is a pause as the timer turns an increment from drain to spin -- the same effect occurs when you open the lid during drain. The transmission doesn't know the difference, it just 'knows' there was a pause and when the motor restarts running in the same direction, SPIN.
If you aren't aware, the motor is reversible -- it runs one direction for agitate, and the other direction for drain AND spin. During agitation, there are some cams and other mechanisms in the transmission that preset themselves so that when the motor stops and reverses, it will first do a neutral drain. Then when the motor pauses and restarts again in the reverse direction, the cams 'release' and shift the tranny into spin instead of neutral drain.
The very first direct-drive machines didn't have the neutral drain -- they had no choice but to spin-drain.