Processing pending events before exiting (issue #65)