So I've had this in two worlds/playthroughs now, and both times, it seemed to start after defeating queen bee specifically.
I assume it's when the game autosaves as I use a mod that makes the game autosave more frequently when this happens.
When it happens, I suddenly get sent to a screen that can say different things, like backing up player data, generating map, etc.
If I get one that displays a percentage, and use overhaul mod's configuration menu to escape the infinite screen, go back into the world and get the sudden exit again, this percentage increases each time it happens without exiting tmodloader.
I have a sneaking suspicion that this is somehow caused by secrets of the shadows, or a conflict between it and another mod, as so far it seemingly has only happened in worlds with it enabled.
I'll have to put the logs in a reply to this, as I am making this on a seperate device (as it is hard to type on a steam deck.)
I tried reading the logs, however the log for client.txt is very long, but I assume the more relevant info is near the bottom.