A lot of skill (and a little luck).
Here is an amazing video of what appears to be an engine failure over an urban area. The pilot did a great job. It got the observer's heart going though! If only every engine failure had such a good outcome.
Raw Video: SAPD Helicopter Emergency Landing - Video - KSAT San Antonio
500 Fan.