After you are finished collecting data for a query, call the PdhCloseQuery function to close the query and release all allocated system resources. The function closes all counter handles associated with the query.