rfc2136handler: Close socket when write fails

Fix for Coverity CID 1066217.
Merge pull request #978 from zeha/coverity

Fixes for a Coverity detected issue in rfc2316handler