Add extra checks on connection::recv exception

Make sure we catch the "context termination" exception, so it is
possible to exit cleanly.