When the ball swings to the other metal bar, excess electrons again try to spread out their negative charge. This drives some of the electrons into the bar.
This bar is "grounded" by the green wire. This means that electrons can flow all the way into the earth. The electrons thus have the ultimate opportunity to spread apart and reduce the repulsive forces between them.
This discharges both the ball and 2nd rod, leaving a balance of positive and negative charges. The ball therefore no longer feels an electrostatic force and begins to swing back.