Fix bug: correctly handle StreamClosedError when persistent connection.