Not all the operating system is shut down.
There is still bare consciousness, bare awareness, the listener when you talk to yourself.
It is possible to maintain this awareness through transition into sleep, which is known as lucid dreaming.
There’s much in human consciousness that defies reduction to software and hardware.
True. I remember reading somewhere that the one sense that never completely shuts down and is the first to come on line is our sense of smell.
And while mattress makers would have us believe "tossing-and-turning" while we sleep is bad for us* it's perfectly normal...and necessary. While we sleep our body has us flop around every now and then to keep pressure points from forming: Pressure points -> Bed Sores> Gangrene
*(+ the sign of a crummy mattress which, of course, needs to be replaced by one of their fine mattresses.)