Fix possible leak when a write is rejected