Fix possible NullPointerExceptions

If creation of the ZipFile and JarFile instances fails, those variables will be null and the finally block will throw a NPE. This patch adds a check to ensure null resources aren't closed.