Adding event handling for quit event