getMappings() strange behaviour

Hi, I’m going crazy around this:

I subclass KeyMappingEditorComponent in a class called KeyCommandsComponent and put it inside KeyCommandsWindow that is a subclass of DocumentWindow.

Problem is this: When I close my KeyMappingEditorComponent using the close button of the KeyCommandsWindow everything is ok and in destructor of KeyCommandsComponent I can store the mapping, but when I shut down the app while KeyCommandsComponent (contained in KeyCommandsWindow) is yet on desktop mappings are deleted and

DBG(getMappings().createXml(false)->toString());

gives me this:

<?xml version="1.0" encoding="UTF-8"?>

<KEYMAPPINGS basedOnDefaults="0"/>

this the destructor of KeyCommandsComponent:

    ~KeyCommandsComponent()
    {
        DBG(getMappings().createXml(false)->toString()); 
        getAppKeyCommandsStoredFile().replaceWithText(getMappings().createXml(false)->toString());
    }

this the destructor of KeyCommandsWindow:

~KeyCommandsWindow() override
    {
        applicationProperties.getUserSettings()->setValue ("KeyCommandEditorPos", getWindowStateAsString());
        clearContentComponent();
    }

    void closeButtonPressed() override //this is not called when I shut down the app
    {
        owner->keyCommandsWindow.reset();
    }

When I close KeyCommandsComponent with the close button all my commands are printed at this calling DBG(getMappings().createXml(false)->toString());