Allow runAsMainSingleModule to be called more than once

Call finalizeForCommandLine even if an exception is thrown so that it is
OK to call runAsMainSingleModule again. This allows this (and the calling
runAsMain as e.g. used in the template) be called from some framework which
doesn't reset globals.

Change-Id: I9eff770e06feef90f99ec0445bd294816f8b6a0a