Fixing exception handling to make zktool exit correctly on error

Refactored the main method to pull out different handling of flags that are independent.
Added a finally clause to close cloudname to allow the main method to return in case of an exception.