[SPARK-3627] - [yarn] - fix exit code and final status reporting to RM

See the description and whats handled in the jira comment: https://issues.apache.org/jira/browse/SPARK-3627?focusedCommentId=14150013&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14150013

This does not handle yarn client mode reporting of the driver to the AM.   I think that should be handled when we make it an unmanaged AM.

I still think we should catch only Exception here. All we ever do in `finish` is to kill the threads and log the exit code, and if we get a really bad `Throwable` that kills the JVM then these threads won't survive anyway. It's just that the JVM is not guaranteed to do whatever `finish` does properly.