Separating gas-giant and ice-giant planets by halting pebble accretion