Working on session management

Working on proper ways to close things.