You will receive money from the 1st pillar, governmental retirement provision, when you retire. Until then, the contributions remain in Switzerland. The requirement for a pension is that you have paid into the 1st pillar for at least one year.
Money in the 2nd pillar, occupational retirement provision, is personally-saved retirement assets. You will receive this money when you leave Switzerland. However, a distinction is made between the mandatory and super-mandatory part. If you move to an EU or EFTA country, only the super-mandatory part of the occupational retirement provision will be paid out to you. The mandatory credit is transferred to a [vested benefits account (https://www.zurich.ch/en/private-customers/retirement-provision-assets/assets-investments/vested-benefit-solution-funds). You will then receive the amount on the vested benefits account upon retirement. However, if you emigrate to a country that is outside the EU and EFTA countries, then you will receive the entire credit balance from the pension fund.