SPARK-2134: Report metrics before application finishes

Ouch, my apologies. I should compiled this before pushing the new change.