Fixed a crash because we forgot to remove the undo stack of a node when it was destroyed.