Fix #325 - don't leak references in client shutdown code
Merge pull request #326 from humphd/issue325

Fix #325 - don't leak references in client shutdown code