The market value at the end of the 6 year rental period is irrelevant.
The capital gain in simple terms is the sale price - the market value when first earned income apportioned to exclude the 6 year period. i.e. as per your example if you sell 10 years after moving out then the taxable...