BUG-904 fix closing session

@hermanschaaf 
after this is merged please update the pip version with a new release.