SERVER-9474 SERVER-9421 fix replset tests with background index builds

Lock the DBWrite lock before stopping index builds.
Avoid touching non-PODs while looking at non-threadsafe CurOp structures.
Fix the way we exit the batch-builder loop for replsettests
(this was broken by SERVER-9474's commit)