Show confirmation dialog before session is terminated

Is it possible to show a confirmation dialog allowing the user to cancel before a session window is closed?