Motion correction gives unusual results in shift

This seems very similar to this bug. Try full-frame motion or set the “Last frame” parameter to N-1 (e.g. 39 if you have 40-frame movies).