Cancel writes

Proposed fix for #2209