The plane maker has agreed to pay $1.1bn to avoid prosecution over two fatal crashes that killed 346 people.