If your enrollment in the HSA-eligible medical plan ends during the year, your maximum HSA contribution will be calculated on a month-by-month basis for your months of enrollment in the HSA-eligible medical plan and your coverage level(s) during those months.
If you continue to be HSA-eligible until the end of the year, you will be allowed to make the full contribution, subject to any adjustment for a change in coverage levels.
Otherwise, when you end coverage, contributions exceeding the pro-rated amount allowed are subject to a 10% penalty. This is different than contributions that exceed the yearly contribution limit.
Example: You have self-only coverage for the first 6 months of the year. You then cancel your coverage because you will be covered under your spouse’s plan. Your maximum HSA contribution for the year will be one-half the self-only maximum (plus one-half the catch-up contribution, if you are age 55 or older). If you have contributed more than that, you will pay a 10% penalty on the excess and the earnings on it. The 10% penalty applies to each tax year the excess contribution remains in the account.