Bugfix/dont dequeue closed sessions from pool

The new implementation of the session pool can dequeue a closed session if its the only one in the pool.