How does Mac pause upgrade when close the lid? I'm upgrading macOS High Sierra. During upgrading, I close the lid for some time, then open the lid to see if upgrade finished. But when I open the lid, the system continue to upgrade from the progress I left. How does Mac do this?

I mean it needs an operating system to control pause/resume, but the OS is under upgrading, how can it control the computer?
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.