Orange Pi 3B trixy ssh sessions not closed

This summer I installed dietpi Bookworm on an Orange Pi 3B
The basic install using an unmodified dietpi.txt worked eventually, but a customized install with modified entries in dietpi.txt like static IP, timezone, password were not used or set. So did not work as expected.
So I had to configure many thing manually using dietpi-config and editing config files, setting the proper date.time etc.
But after that I finally had a basic Dietpi bookworm installation.

I did not continue for a while but a few weeks ago I tried to update this basic installation to Trixy.
That worked ok I guess, but the trixy install would not shutdown properly. It does shutdown, but the ssh session is not closed properly when using poweroff, reboot etc commands.

It threw errors like:
Failed to connect to system scope bus via local transport: No such file or directory

I searched for this and installed dbus etc but that did not help.

Because I like to have a properly behaving basic system I started over and reinstalled a fresh trixy image.
Again I tried to to customize a few items with modified variables in dietpi.txt such as static IP, no wireless, timezone, passwordt etc.
But that did not work at all. The first boot seemed to use the modified items, but nothing happens. The second boot does run and update the system but it reboots automatically. Then I could not log into the system because using neither the default nor the custum set password are accepted by the ssh session.
So I started again with a clean unmodified dietpi.txt Trixy install. After that I again had to spend quite some time to configure the system as desired. I only installed openssh as SSH service instead of dropbear. Other additional software I did not install yet.
So I now had a basic Trixy install, configured as desired. But to my disappointment: this basic Trixy install does not close the ssh session properly as well.

Assuming that maybe the masked loginid was related to this behaviour I installed the missing items manually:
In order # Unmask (enable) systemd-logind service (including dbus), which is masked by default on DietPi
AUTO_UNMASK_LOGIND=0
I changed this manually using:
systemctl unmask systemd-logind
apt install dbus
systemctl start dbus systemd-logind

However there was no difference. Ssh sessions are still not closed properly.
How can i solve this?

I think I found e solution or workaround myself:
first I created the ssh-session-cleanup.service but that didi not help.
Then : apt install libpam-systemd
Reboot and it sort of worked OK. Not very clean, because every time I get a message:
root@DietPi:~# client_loop: send disconnect: Broken pipe
I never had that message with Bookworm or previous Debian versions before.
What I have learned from this case:
proper shutting down a SHH session on a debian server uses a sequence that terminates various running processes. Also depending on de speed of the hardware it can happen that the network connection is dropped before the ssh connection is closed. Hense the ssh-session-cleanup.service. This should shut down various proccesses in the right order.
However, that did not work for me. Maybe modifying the shutdown service sequence like here:
https://www.reddit.com/r/raspberry_pi/comments/s055tg/ssh_sessions_hang_on_rebootpoweroff/
will behave better, but ignoring the message broken pipe does not bother me. So I see this as an acceptable workaround.