Hopefully fix 'TypeError: Cannot call method 'close' of undefined'.