Description
Describe the bug
When a node is booting and some application is in starting state. If the node got an shutdown signal, the application_controller will do the terminate step.
However, this step only tries to stop applications that are in running state, but ignore all the starting applications
https://github.com/erlang/otp/blob/master/lib/kernel/src/application_controller.erl#L1266
This will cause an unexpected shutdown sequence.
To Reproduce
start two applications which sleeps on boot
shutdown the node before second application started
we will see first application shutdown before the second one
Expected behavior
Later starting application should be shutdown earlier than previously started ones.
Affected versions
OTP 26
This issue must exist for a really long time since very early version, surprised if it has not been reported
Additional context
I'm thinking that an option can be added to kernel that waits the starting application to finish boot (by repeatedly reading ac_tab or waiting a finish message) before shutting down the node, so that everything can happen gracefully.