Add condition on connection close
Merge pull request #693 from andrerod/dev

Add condition on connection close