Close properly the connection and the session when the listener die