Stop exporting messages if the client goes away

If the client disconnects during a large message export, we currently continue fetching and processing all the messages even though there's nobody listening for them.