Fix 'Do not exit after a template has been output' (see #5570)