From the title of your post, about AHV, and the content of your post about pension contributions, I’m not completely sure whether you mean „AHV“ (the state retirement fund, also called „1st pillar“) or are perhaps referring to your contributions to the mandatory pension plan of your employer (also called “2nd pillar”, or “Pensionskasse”, or referred to the law governing it: BVG, in German).
Sorry if I’ve misunderstood.
Perhaps some of these links will help towards answering your question.
How the Swiss pension system works: https://www.ch.ch/en/retirement-provision-system/
This is about leaving Switzerland: https://www.ch.ch/en/search/?search_...witzerland+ahv
This is what happens if you leave the money in Switzerland until your normal old-age retirement age: https://www.ch.ch/en/retirement-benefits/