The deal ends a federal criminal investigation over environmental pollution and absolves liability for the embattled company while preserving money for cleanup.