TEZ-1216. Clean up the staging directory when the application completes.

Still need to track why the shutdown hook is getting invoked when the shutdown handler is still running. For now added a safety check.