This happens when there is an incorrect refcount on the editor object, so it is not being properly disconnected from the grid before it is destroyed. There is more info about this here: HOWTO: Deal with reference counts in Grid classes and some additional discussion about it here: https://github.com/wxWidgets/Phoenix/issues/627 and probably other places you can find with Google.
So, in a nutshell, you need to call DecRef on the editor when the program is shutting down, before the grid is destroyed.