A headshunt (or escape track in the United States) is a short length of track provided to release locomotives at terminal platforms, or to allow shunting to take place clear of main lines.
A terminal headshunt is a short length of track that allows a locomotive to uncouple from its train, move forward, and then run back past it on a parallel track. Such headshunts are typically installed at a terminal station to allow the locomotive of an arriving train to move to the opposite end of (in railway parlance, 'run around') its train, so that it can then haul the same train out of the station in the other direction (assuming, of course, that it is a locomotive equipped to run in either direction; for older, one-way equipment such as steam locomotives and cab unit locomotives, a wye or turntable needs to be provided to physically turn the engine around, as well as a run-around track).
Found primarily on metro systems, rapid transit light rail networks, and tramways, a reversing headshunt allows certain trains or trams to change direction, even on lines with high traffic flow, whilst others continue through the station. Typically there will be two running lines, one for each direction of travel, and the headshunt will be positioned between the two running lines, linked to both by points. Although most trains will pass through the station and continue in the same direction, an individual train may be directed into the reversing headshunt, before exiting onto the other running line, in the opposite direction of travel. This procedure allows a greater frequency of trains on a city-centre section of the line, and reduced frequency on the suburban sections, by allowing certain trains to shuttle back and forth only on the city centre part, using the reversing headshunts to change direction within the flow of trains.