Remove node from a container before destroying it. Thanks to Alexander Potapenko for pointing this out.