c++ destructors check handle validity. Fixes #2