add event when close window