Shutdown hooks for output codecs

I'm trying to write a batching codec, and need to flush the batch on shutdown. I've implemented the close method but that does no appear to get called. From what I can see of the pipeline code this only gets called on input. Is there a way to implement shut down code on an output codec.