Ensure that metrics and alarms are flushed on shutdown and that the Kafka
connection is shutdown properly also. This ensure that on normal shutdown,
no metrics or alarms are missed or duplicated.

Some changes were also done to remove warnings for generics.

Some unused instance properties were removed.