Fix memory and resource leak on closed Sessions (JAVA-342, JAVA-390).