set writer to nil when closed