pump_messages: properly exit receive loop when disconnected.