BindTo declaration makes WAM stop when compositor stops. Compositor wayland socket is a hard dependency in WAM side, wo we do really expect this, and the best way is to shutdown WAM before compositor in the procedure to shutdown the session. That fixes, as said, part of the problem.
The other part is about apps launched by applaunchd. Ideally, we should move to use DBUS activation instead of the launcher process, so we don't even need an extra process, and we can know if an app is running or not.
Also, we are going to replace the custom IPC socket protocol.
While we do not do that, it should be enough to just kill all those processes or detect that the WAM web socket is not useful anymore. Though, I agree, applaunchd should also take care of killing the children it activated when it is shut down.
A simple systemctl restart agl-session@agl-driver would basically crash, though just a simple stop start works fine.