fixing a issue in acquiring locks in ApplicationTerminatedMessageProcessor