Add teardown to flush elasticsearch on agent shutdown

Prior to this, some events could be lost if logstash was shutdown.
Merge pull request #1175 from jordansissel/fix-es-flush-on-termination

Add teardown to flush elasticsearch on agent shutdown