At inception of a CDS, the CDS spread (and the upfront premium) is computed based on the credit quality of the reference entity. After inception, the credit quality of the reference entity (or the credit risk premium in the overall market) may change. This will lead to the underlying CDS having a nonzero value. For example, if the credit spread declines, the protection seller, having locked in a higher credit spread at initiation, would gain.
The change in value of a CDS after inception can be approximated by the change in spread multiplied by the duration of the CDS:
profit for protection buyer ≈ change in spread × duration × notional principal
profit for protection buyer (%) ≈ change in spread (%) × duration
Note that the protection buyer is short credit risk and hence benefits (i.e., profit is positive) when credit spreads widen.
The protection buyer (or seller) can unwind an existing CDS exposure (prior to expiration or default) by entering into an offsetting transaction. For example, a protection buyer can remove his exposure to the CDS by selling protection with the same terms as the original CDS and maturity equal to the remaining maturity on the existing CDS.