ldp: avoid calling write in destructors