Added explicit close call on (re)connect