In IRS Publication 969, the IRS defines the “Last Month Rule.” According to this, if you have an HDHP on the first day of the last month of your tax year (December 1 for most tax payers), you can contribute up to the maximum HSA contribution for that year based on your coverage type (individual or family) regardless of when your HSA is open. An important thing to note is that you may face penalties if you don’t remain enrolled in an HDHP during what’s referred to as the “testing period.” For the last-month rule, the testing period begins with the last month of your tax year and ends on the last day of the 12th month following that month (for example, December 1, 2018, through December 31, 2019). You can read more about this here.
Source: "Publication 969 (2018), Health Savings Accounts and Other Tax-Favored Health Plans.”
Updated: