Stabilization of Z pinch by velocity shear