Alternative solution to fix #345.
Fixed Unknown state on disconnect error message generated when closing  connections.
Merge pull request #346 from eandersson/master

Alternative solution to fix #345.