You sell it and buy a new one. It does not expire. This is conceptually no different from rolling futures if you're more familiar there.
It seems you haven't gotten the gist of the other answer so I'll try to phrase it more clearly. (I don't know much about CDS/CDX so I'm taking the other answerer's word on what the market is like as correct.)
Say you own some single-name CDS. Say contracts for this name are issued semiannually in Mar and Sep and have a maturity of 5 years. The most recently issued contract is called 'on the run' and it is the most actively traded contract. Say we're before the Sep contract is issued and we have a position in the contract issued Mar17 (which expires Mar22). Once the Sep is issued, we're going to roll to the September, which means we sell our Mar22 contracts and buy Sep22. So we sell an off-the-run 4.5y contract and buy the on-the-run 5y contract.
Why do we do this rather than holding? Mostly because the on-the-run is more liquid so unless we're positive we want exposure for the length of the contract, it's good to have one that you can trade out of easily.
Eventually, if we wanted to keep our exposure, we would need to buy a new contract when the old one expires. This is sort of a last-minute roll.
This is a bit different from futures where the active contract typically expires next month and we need to roll to the next next month if we want to keep our position and not take delivery.
We also might have initially hedged some transaction with the active contract for liquidity reasons, but actually we want to ultimately be hedged with longer maturities. Then, we're going to roll our position in the active contract to a longer maturity when we get a good opportunity to, which means we sell our short-dated contracts and buy longer dated ones.