If you pay the HOA fees in advance, then your extra funds will be viewed as a liability by the HOA. Over the next six months that liability will decrease. You will then have to start paying the fee when the balance returns to zero. I have known people who did this, they paid the entire year in one payment. I don't think it saved them any money, but it did mean they didn't have to remember to mail a check every month. It was that long ago, that there was no way to pay it except by check. I guess they saved 11 stamps and envelopes. One word of caution, pay attention to the month they decide on the new HOA rate, or you might discover that you only paid for 5 and 7/8 months, and get surprised by a late fee.
If the HOA was to collapse then you would have to see if they can refund your excess payments. You might be treated just like anybody else that they owed money to. Of course the HOA should have money stored in a reserve fund to replace the roof, so they may owe every member some money.
Don't do this if you will be selling within that 6 month period, it just makes one more thing to be addressed at closing.
Now looking at the mortgage.
If the insurance company was to pay off the mortgage, then everything above the mortgage balance would be yours to keep. You wouldn't lose the money.
Of course most mortgages will limit how far in advance you can pay. They will allow you to pay extra to reduce the balance, but that allows you you pay it off quicker, it doesn't let you skip payments. Find out if they will allow you to pay ahead more than a month or two.
I am not sure what this accomplishes. If you pull the money from your emergency funds to pay the mortgage and HOA six months ahead, you still have to rebuild the emergency fund up during those six months.