Distinguish between closing window and quitting application