The deal ends a California trial and requires sweeping safety changes to Instagram and Facebook for teen users.