Fixes #430, call quit at the right times instead of based on logLevel