Fix leaking json generator handle on shutdown