State estimated taxes are deducted as itemized deductions for the year in which they are paid. For example, 2017 state estimated income taxes paid on April 18, 2017, June 15, 2017, and September 15, 2017, are deducted on the 2017 federal income tax return. The final installment of 2017 state estimated income taxes paid on January 16, 2018, are deductible on the 2018 federal income tax return (subject to the new $10,000 cap on deductible state and local taxes). However, the final estimated tax payment for 2016 that was made in January 2017 is part of the 2017 itemized deduction for state and local income taxes.
On a sale of a principal residence, you may avoid tax under the rules.