The accepted answer on codepen works nicely, however when I implement similar version on my IDE, I have the same problem of the slider not going down to zero. I did get it working however by setting the slider's range to [-20,10]:
<input type="range" step="1" min="-20" max="10" class="range-slider" value="-10" />
I adjusted the values so that the float values range from -1 to 0.5. That way it can be attenuated to zero:
volume_slider.oninput = function () {
let valFloat = parseFloat(this.value)/20;
gain.gain.rampTo(valFloat, 0.1);
}