Make sure we close files properly