Make sure there’s not a book, cat, whatever, resting on the keyboard. Most recently I experienced that same symptom was on a diskless Unix box that serves my TV. It had a wireless keyboard that is rarely used and so tucked down the side of the TV cabinet. Somehow it had got disturbed so the ESC key was squashed and trapped down, instantly reawakening it every time I shut it down.
It’s a while since I used Microsoft’s Operating Systems, but I vaguely recall a couple of issues I tracked down, that were interfering with Windows sleep/shutdown.
One was if a remote machine was connected to file an XP box that offered file sharing, it would prevent the XP box from sleeping.
Another was, if the machine crashed during shutdown, and was configured to restart automatically after crashes well... it did exactly that.
I also tend to be mistrustful of the BIOS option, Wake on Lan. If not needed, I disable it.
... just a few suggestions.