When a permanent with haunt is put into the graveyard or when a Sorcery or Instant with haunt resolves, the card is removed from the game "haunting" a creature. When the haunted permanent is put into a graveyard the card haunting it has its haunt ability triggered
(from comprehensive rulebook)
502.51a Haunt is a triggered ability. “Haunt” on a permanent means “When this permanent is put into a graveyard from play, remove it from the game haunting target creature.” “Haunt” on an instant or sorcery spell means “When this spell is put into a graveyard during its resolution, remove it from the game haunting target creature.”
502.51b Cards that are in the removed-from-the-game zone as the result of a haunt ability “haunt” the creature targeted by that ability. The phrase “creature it haunts” refers to the object targeted by the haunt ability, regardless of whether or not that object is still a creature.
502.51c Triggered abilities of cards with haunt that refer to the haunted creature can trigger in the removed-from-the-game zone.