Fix live dev issues after ResearchLiveHTML merge

Replaces pull #4969

Fixes #4966 and #4972.

Fixes failing unit "in-memory" live dev test where event handlers were not removed properly and caused an error in `RemoteAgent` when trying to communicate with a closed Inspector connection.