The U.S. Department of Justice says the Safeway grocery store chain has agreed to pay $3 million to settle allegations of not reporting theft or loss of controlled substances at its pharmacies in a timely manner.

The settlement, announced Tuesday, closes an investigation that began with Safeway stores in North Bend, Wash. and Wasilla, Alaska in April 2014. For months, the stores had failed to notify the Drug Enforcement Administration that employees had stolen tens of thousands of hydrocodone tablets.

Investigators eventually reviewed practices at all Safeway pharmacies from 2009 to 2014, and they found that Safeway pharmacies frequently failed to report drug thefts promptly to the DEA.

Safeway said in a statement, “Since early 2015, the Company has significantly enhanced its controlled substance monitoring program and implemented a variety of improved policies and procedures to enforce compliance with the Controlled Substances Act.”

Safeway also said that they would suspend filling prescriptions for controlled substances for four months at its North Bend in-store pharmacy. The grocery chain will also close an in-store pharmacy in Belmont, Calif.

Seattle U.S. Attorney Annette Hayes says pharmacies have a key role in ensuring that only those with legitimate prescriptions obtain the powerful and addictive narcotics.

Safeway is a subsidiary of Boise-based Albertson's Companies.

The Associated Press contributed to this report.