Fixes #1410 where newChild.parent could be set to undefined before use

As pointed out, `newChild.parent` could be accessed after it was set to
undefined. This fix unifies the code from the various `GameObject#destroy` methods so
the previous issue does not occur.