Added exception handling for proper EXIT button usage