alarms: Fix several resource leak and shutdown problems

- Fixes issues with transactions not being rolled back in case of
  failures.

- Fixes issues with shutting persistence manager factory while
  writing to it (caused JDO exceptions stating that there were
  still active transactions).

Note that the AppenderBase base class already checks whether the
appender is started and synchronizes on the object when calling
append().

Target: trunk
Request: 2.11
Require-notes: yes
Require-book: no
Acked-by: Albert Rossi <arossi@fnal.gov>
Patch: https://rb.dcache.org/r/7557/
(cherry picked from commit d9c3b50fe51e7b3d4da4cd062e573b6892effb16)