md: avoid races when stopping resync.