(maybe) improved resource closing