The game ends when The Machine moves onto the Bonus token space a second time, after completing its second full lap around the Basin board. When this happens, add the Fountain tiles at the other Basin pawn spaces to The Machine’s area, and move on to Final Rewards.
Final Rewards are scored in the same manner as above. If you have more points than The Machine, you win! If you cannot outscore it, you lose and humanity has failed against The Machines. Better luck next time.