Basically, the kernel freezes the GUI tasks when the display is turned off so that they don't run but also don't exit. When the display is turned back on again or a command returns any exit code, all GUI tasks are unfrozen. And this loads right before the first process that the init system launches.