closing connection whenever there is any error in handleconnection