Prevent potential NPEs when close() is called