add exit listener