Fixed to properly handle unconfirmed messages on shutdown