Check is connection set before close it