Fix scope of destructor