Add CloseConnection function