It's a legitimate tax question, and affects separating couples. If your spouse dies during the year, you are married for the year if you were married on the date of your spouse's death. So, you may be unmarried, or engaged, or even getting cold feet, for 364 days, but if you tie the knot on Dec 31, you can romantically file a joint tax return.
Some people try to divorce once a year when to do so is to their tax advantage.
The courts do not recognize such divorces for tax purposes, concluding they are a tax sham even if the divorce is technically valid in the state. Other times, a couple will divorce in one state and seek to have it recognized in another for tax purposes. Generally, that's ok, and the IRS honors those as well. However, watch the details. In some states, you can divorce on December 31, but if the time for appeal has not expired, you are still married for tax purposes until that time.