I had this happen while fighting moonlord too. As soon as I died game crashed. I thought it was related to a crash problem I'm having after surviving boss fights as well, but maybe they are separate issues.
Basically my tally is:
-2 crashes seconds after killing empress during the day
-1 crash just as I died to moonlord
-1 crash in the middle of an event. I think it was an eclipse but may have been one of the moon events. I can't remember as I was doing them all back to back.
All 4 were on new master worlds with an old character, all 4 resulted in character progress loss to last logout, but saved the world state. I was alone tho, no multi-player, so I suppose it's possible the moonlord death was a repeat of OPs issue, and the other 3 were caused by something else. Not sure what to think.