As a Discovery Writer, I live for those moments, I absolutely want my characters to surprise me and act on their own.
At the start of the story, all my characters are malformed lumps of clay; I have imposed upon them some basic personality type, but that is just a veneer they wear, their "every day" personality.
Under stress, they reveal their true selves; their unguarded selves. Beats me what that is! Whatever feels appropriate to them in the moment.
But once I find it, I go back to the beginning, and reshape that lump of clay, to better reflect who they really are, AND whatever veneer they wear.
In normal life, this girl is sweet, joking, and gets along. Under stress, she is calculating and ruthless and takes no prisoners. Of course there are alternatives, but when somebody tried to rape her, she had an opportunity and blinded him for life. And she feels no regret for it. She doesn't brag or talk about it, she won't even admit it was intentional. She changes the subject when it comes up, and returns to being sweet, joking, and getting along. But my readers know she doesn't cower under pressure, she is stone cold analytical and as ruthless as they come. Any time she is threatened, the reader feels tension about how she will react; because in their mind cowering is off the table.
As far as I am concerned, characters that feel like they have their own minds are pure gold. Now that you know who that character is, rewrite whatever you need to make this consistent, both their easygoing character and this underlying whatever-you-found, be it steel or dung.
Chances are your subconscious tossed you this one over the fence, knowing you need more drama and realism in your story. Let your subconscious be your collaborator. As you write, you subconsciously build models of your characters as if they are real people, not just puppets on your stage. Your subconscious is telling you, based on what it knows so far, this is how that person should react. It should do that with all your main characters, and this is great, your sub knows better than you what a consistent person is like, with both light and dark in their personality, both grief and joy in their past.
If you need to adjust your ending to make it plausible, given this change in character, do it. We write scenes from our imagination, but the subconscious does 95% of the work in making imagination realistic. Consciously we pick the words and order, what is important to convey in the moment, but the subconscious is providing the imagery and simulating the characters, what they are feeling and thinking.
Trust it. If your subconscious says your character is aggressive/dismissive in this circumstance, then based on what has happened before, it has concluded the character's kind/warm exterior is too unrealistic, and under stress their core is exposed. Perhaps for this character it is a matter of choice, or childhood training and discipline, to be kind/warm. Perhaps they have always gone along, to please Mama and Papa, to be a good boy and get their praise, suppressing their natural more aggressive and dominating urges.
Go with that. It is a gift from your subconscious. It has developed a character with depth and layers and skills you did not design in. Revisit your story, and see where hints of this deeper personality might be foreshadowed or hinted at. Incidents from the past, recalled, perhaps, that your character blows off as no big deal.