Safe onDestroy(). Fixes #528