Closing the session before closing the socket, seems to fix the issue #4...

....