Extra assurance

It doesn't iterate elements more than once.
Make sure cleanup errors don't halt unloading

It would leave plugins in a half-loaded state.