Fix missing close on error