Fix Exception for f:close() when f==nil