OpenHAB shutdown only after killing processes

Hi,

shutting down OpenHAB takes quite long time. If terminates after killing more than 100 processes.

Those messages are in the journal/syslog.

2025-11-22T13:42:03.021858+01:00 oh-system systemd[1]: openhab.service: State ‘stop-sigterm’ timed out. Killing.
2025-11-22T13:42:03.022491+01:00 oh-system systemd[1]: openhab.service: Killing process 798 (java) with signal SIGKILL.
< about 100 other similar messages >
2025-11-22T13:42:03.026653+01:00 oh-system systemd[1]: openhab.service: Killing process 3509732 (n/a) with signal SIGKILL.
2025-11-22T13:42:03.086599+01:00 oh-system systemd[1]: openhab.service: Main process exited, code=killed, status=9/KILL
2025-11-22T13:42:03.086700+01:00 oh-system systemd[1]: openhab.service: Failed with result 'timeout'.
2025-11-22T13:42:03.086976+01:00 oh-system systemd[1]: Stopped openhab.service - openHAB - empowering the smart home.
2025-11-22T13:42:03.087050+01:00 oh-system systemd[1]: openhab.service: Consumed 3h 22min 25.394s CPU time, 1.2G memory peak, 180.1M memory swap peak.

Before the these messages there are about 2500 lines like these:

2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]: org.osgi.framework.BundleException: Unable to acquire the state change lock for the module: osgi.identity; type="osgi.bundle"; version:Version="3.18.0.v20220516-2155"; osgi.identity="org.eclipse.osgi"; singleton:="true" [id=0] STOPPED [STOPPED]
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]: #011at org.eclipse.osgi.container.Module.lockStateChange(Module.java:350)
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]: #011at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle$EquinoxSystemModule.asyncStop(EquinoxBundle.java:217)
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]: #011at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle.stop(EquinoxBundle.java:324)
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]: #011at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle.stop(EquinoxBundle.java:329)
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]: #011at org.eclipse.osgi.launch.Equinox.stop(Equinox.java:149)
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]: #011at org.apache.karaf.main.Main.lambda$registerSignalHandler$0(Main.java:387)
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]: #011at java.base/java.lang.Thread.run(Thread.java:1583)
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]: Caused by: java.util.concurrent.TimeoutException: Timeout after waiting 30 seconds to acquire the lock.
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]: #011at org.eclipse.osgi.container.Module.lockStateChange(Module.java:347)
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]: #011... 6 more
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]: Caused by: org.eclipse.osgi.framework.util.ThreadInfoReport: Thread dump
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]: ThreadId: 1 ThreadName: main ThreadState: WAITING
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]:  Blocked On: java.util.concurrent.atomic.AtomicReference@7646a2a0 LockOwnerId: -1 LockOwnerName: null
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]:  Synchronizers Locked: none
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]:  Monitors Locked: none
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]:  Stack Trace:
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]:    java.base@21.0.9/java.lang.Object.wait0(Native Method)
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]:    java.base@21.0.9/java.lang.Object.wait(Object.java:366)
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]:    org.eclipse.osgi.container.SystemModule.waitForStop(SystemModule.java:173)
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]:    org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle.waitForStop(EquinoxBundle.java:312)
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]:    org.eclipse.osgi.launch.Equinox.waitForStop(Equinox.java:217)
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]:    app//org.apache.karaf.main.Main.awaitShutdown(Main.java:704)
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]:    app//org.apache.karaf.main.Main.main(Main.java:193)
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]: ThreadId: 9 ThreadName: Reference Handler ThreadState: RUNNABLE
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]:  Blocked On: none
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]:  Synchronizers Locked: none
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]:  Monitors Locked: none
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]:  Stack Trace:
2025-11-22T13:39:32.968755+01:00 oh-system karaf[798]:    java.base@21.0.9/java.lang.ref.Reference.waitForReferencePendingList(Native Method)
2025-11-22T13:39:33.011841+01:00 oh-system karaf[798]:    java.base@21.0.9/java.lang.ref.Reference.processPendingReferences(Reference.java:246)
2025-11-22T13:39:33.011841+01:00 oh-system karaf[798]:    java.base@21.0.9/java.lang.ref.Reference$ReferenceHandler.run(Reference.java:208)
2025-11-22T13:39:33.011841+01:00 oh-system karaf[798]: ThreadId: 10 ThreadName: Finalizer ThreadState: WAITING

These are the installed add-ons, but 99% of the automation is HABApp, which terminates flawlessly.

automation = jsscripting
binding = astro,dwdunwetter,enocean,exec,gardena,icalendar,mqtt,network,networkupstools,ntp,onewire,snmp,tankerkoenig,telegram
persistence = mapdb,influxdb
transformation = jsonpath,map,scale
ui = basic

If desired, I can provide the full set of data and any further information.

This no new phenomenon, I have such problems since several OpenHAB versions but I never looked into it in detail. Currently I’m using openHAB 5.0.2 on Debian/Trixie. At runtime the system is performing well.