server/state: Tweak synchronization to avoid deadlocks at shutdown