example 6-2: trapping exits