change state to disconnected when connection ends/closed
Merge pull request #268 from celalo/patch-1

change state to disconnected when connection ends/closed