Disable the frontend when the extension is disabled/has restarted

When the extension is disabled/has been restarted, all the ports open in content scripts are disconnected. Since we never do this ourselves, we can use it to detect when the extension is no longer functional and disable the frontend.

This fixes #1285 (or at least the new issue it raised; the remainder is a dup of #1176).