SPARK-2134: Report metrics before application finishes

FYI:

Although I have added reports to be triggered here and in the Worker before shutdown, I am not sure how a graceful shutdown of Master and Worker is triggered (because the stop-all.sh scripts kills these services and this code is never executed).