Fixed issue with trying to call .close() on a None