potentially fixes #14, fixes #15
Merge pull request #16 from jiehanzheng/issue14

potentially fixes #14, fixes #15 by explicitly listening on 'close' of res