fixes a potential NullPointerException when session is destroyed