fix segfault in lazy write in destructor