Javier and the others find a spot just before the track curved for them to wait, this spot is where the mata gente will be going slow enough for them to hop on. And this is also where Elena cuts off her hair to look less feminine because there are train gangs and they rape many women.
The plan for the three of them was too get on the train and don't look back, so when the time came they did just that. Javier shouted to Miguel to grab the rung while also holding Elena's hand and somehow Javier also followed behind.
The sun was setting and Javier secured rope to a rail on top of the car and Javier made both Miguel and Elena as safe as they could be