Prevent data loss when an ssl socket is closed by remote