I got it to work by changing
$output.= "\t" . '<option' . ' class="' . esc_attr( $class_name ) . '" value="' . esc_url( $url ) . '">' . esc_html( $text ) . '</option>' . "\n";
to
$output.= "\t" . '<option' . ' class="' . esc_attr( $class_name ) . '" value="' . $term->slug . '">' . esc_html( $text ) . '</option>' . "\n";