Update closeAll function to ensure instance.close() can be executed with...

...out JS error

The prototype of Array may be changed by others, so at least we have to make sure the instance.close is a Function.