Lost Season 6 Episode 16 : The End
Jack and the Man in Black use Desmond to temporarily extinguish the light at the heart of the island. The Man in Black makes himself mortal again and almost kills Jack but Jack and Kate kill him first. Realizing his destiny, Jack sacrifices himself to relight the heart of the island, so his friends can escape on the Ajira plane. Hurley takes Jack's place as protector of the island and makes Ben the new advisor. The flash sideways is revealed to be a type of limbo, or holding pattern, for the main characters, where they reside until accepting their life and death, and are then able to "let go" and "move on" together.