How does Mac pause upgrade when close the lid?
This is managed by the System Management Controller (SMC).

The SMC is basically a chip in Intel-based Macs that manage many of the physical aspects of your Mac. This includes power buttons, LED indicators, cooling fans, how your Mac works in its various sleep modes, and so on.

Because the SMC is a sub-system of your Mac, it is not dependent on an operating system being installed.

You may be interested in reading Reset the System Management Controller (SMC) on your Mac - although there is no reason for you to reset the SMC as it did what it was supposed to do in your case.