Added debug log to session closing and related functions