improved traphandling (fixed error when exit trap was fired too quickly)