Employee was closing the top lids on railroad hopper cars. A lid he lifted & released fell back against his left leg. He lost his balance & fell. His leg was pinned against a walkway (on the top of the hopper car) & he sprained his ankle. His fall was arrested by the safety harness & lanyard he was wearing (EE ended up dangling off top of hopper car).