fix use-after-free when disconnected
Merge pull request #17 from HenryHu/master

fix use-after-free when disconnected