Improved closing connection method

Change-Id: Ib030f9d7938cfa680b54cdd304a4e0f11629b8c2