Just leave the program on, and the AI will eventually learn to stay on the track! It can take any amount of generations, so it might take a while, or be done on the 3rd attempt!
The AI learns with reinforcement learning. Turbowarp link: https://turbowarp.org/1273347293