Quenching of the beam-plasma instability by mode mixing at a density discontinuity