The manpage of reboot() says
(0xa1b2c3d4; since Linux 2.1.30). The message "Restarting system with command '%s'" is printed, and a restart (using the command string given in arg) is performed immediately. If not preceded by a sync(2), data will be lost.
How and when exactly is the command string given in arg is executed during shutdown process?
https://unix.stackexchange.com/a/489651/674 says about
An added confusion here is caused by the fact that the
reboot()system call appears to be capable of running a process to do the restart (however that works)
Is the command string given in arg run before the kernel is shutdown, so can the command do some cleanup before kernel shutdown?