Fix coverity issue (Do not throw std::bad_weak_ptr exception at destructor)