Move to the end of the track and undo the constraints of people on the track. You will have infinite time until the trolly reaches the end, and can thusly save infinite lives by doing so.
Sadly, it takes an infinite amount of time to reach the end of the track. Thankfully, you have infinity time, though it's still inconvenient. An infinite number of people people will die (instead of an infinite number of people), but you'll save an infinite number of people in the end. After an infinite amount of time that will be infinitely better!
Actually, that's assuming that the track is a straight line. The distance from the beginning to the end of the track could be just a few feet, and the distance along the rail and thusly the number of people infinite.