I was playing some rated gen - 8 randoms and I used volt switch on a Marowak (Alolan) but it didn't allow me to switch it. Why did it not allow me to switch? Here's the replay - https://replay.pokemonshowdown.com/gen8randombattle-1468928913
It was because marowak had the ability lighting rod. If the Pokemon you hit with volt switch (or any switching move) is immune to the attack then you don't get to switch out.