How do antiviral medicines get rid of the virus?

They don't. Most antviral drugs suppress replication of viruses without actually killing them. Examples include herpesviruses and hiv. Hiv therapy stops the virus from infecting new cells, but viral dna is still present in resting CD4 cells, and could create new virus if medications were stopped. That's why we can't yet cure hiv.