One way to fix that is to add some code setting the step range really high if the list of monsters is empty:
if(array_length(global.encounter_valid_monsters) < 1){ global.encounter_step_range = [9999, 9999] global.steps_to_next_encounter = 9999 }
For additional stability, go to player_step_fill and add an if statement around line 10 to not count up encounter steps if the limit is 9999:
if(global.steps_to_next_encounter < 9999){ encounter_steps++ }