When the wagon stops, the ball moves forward with respect to both the wagon and the ground.
(the wagon; stops; ) (the ball; moves; forward; T:When the wagon stops)
the wagon the ball
stops moves
forward T:When the wagon stops