ssh to termux server disconnects after X seconds
Thanks to @IrfanLatif I looked at battery options again.

And my phone was in Power Saving mode. When I disabled that, everything worked - whether Termux is running in the foreground or not.

So the problem was not related to the upgrade of Termux.