house sale

I recently sold my home and I lived and own in it 4 1/2 year total. My husband passed away mid 2019 and I ended up going to the ICU due to medical reason a few month after. I have been having problems going to the room my husband was when I was taking care of him and my job was also tied to taking care of my husband so when he passed away I became unemployed and was collecting unemployment until September 2021. I didn't have the funds to keep up with the house after that so I ended up having to have to sell the property. But I was told at first that living their for at least two years would grant me the exclusion of up to 500,000 in taxes from the sale of the house but I later read I needed to have owned the place for at least 5 year for it to count. I read that loss of job or death in the family can help with the exclusion. Is any of my situation able to count as that when I have to file taxes next year?