Disconnect event listener on exit