gateway: Fix missing disconnect when agent exits

The profile can be connected only if (and while) the telephony agent is
registered. If an abrupt disconnection is detected (e.g. crash), make
sure all affected gateways are disconnected.