[fix] Do not crash when connection is closed and we write.