Under the terms of the deal, the refiners will have to install equipment to minimize flaring of hazardous gases and to improve leak-detection and repair programs, among other measures, at six refineries, including one in Anacortes, Wash.