Fixed @COMETMGMT-7: closing connection cleanly