ensure that we handle all pending writes at end