Fix shutdown ordering in DeviceController. (#7430)
Fix shutdown ordering in DeviceController. (#7430)

Before this fix we would tear down some things (importantly the secure
session manager) before starting shutdown of the network layer.  This
would lead to a window of time during which we can still receive
messages while in a partially torn down state, which would leave to
crashes.

Moving network layer shutdown, and in particular platform manager
shutdown, to be first in the shutdown sequence ensures this can't
happen by shutting down the message processing thread before we tear
down any other state.

Fixes https://github.com/project-chip/connectedhomeip/issues/7297
project-chip/connectedhomeip,nestlabs/connectedhomeip,nestlabs/connectedhomeip,project-chip/connectedhomeip,nestlabs/connectedhomeip,project-chip/connectedhomeip,nestlabs/connectedhomeip,project-chip/connectedhomeip,project-chip/connectedhomeip,nestlabs/connectedhomeip,project-chip/connectedhomeip,nestlabs/connectedhomeip,nestlabs/connectedhomeip