Genesis 29:31-35 records the birth and naming of Jacob's first four sons by Leah. Interestingly, it is she who names the children, not Jacob (is he really that disinterested?) and the names, along with the reasoning behind them, seem to give some insight into Leah's handling of the pain of her situation.
When the first son is born, she names him Reuben because she believes YHWH has seen her misery, being relatively unloved by her husband. Her hope is that Jacob will love her now.
But that seems not to be the case. When her second son is born, she names him Simeon because YHWH has heard she is (still) not loved. The fond hopes that surrounded the birth of Reuben were clearly not fulfilled.
Leah's pain evidently continues; when her third son is born she names him Levi, ardently hoping that now at last his birth will cause her husband to be attached to her. It seems a forlorn hope. She has been placed in an intolerable situation and not by her own choice. She is deeply pained at Jacob's rejection of her and longs for him to have a change of heart in order to heal the pain in hers. But it seems Jacob is unmoved by the kindness of YHWH in giving sons to he and Leah and blind to the favour of YHWH towards Leah.
Yet when her fourth son is born, she names him Judah saying, "This time I will praise YHWH". No mention this time of her husband, nor of her desperate desire to be loved and accepted by him (an entirely understandable and legitimate desire).
But Leah, so slighted and demeaned, is not abandoned in her misery and with the birth of Judah she recognises this. No doubt the pain remains but she is able now to praise YHWH out of her pain. Reconciled to her situation, she is able to rejoice in the God who is ever-loving and ever-loyal to his people. "This time" her focus is higher than her husband and her joy greater than he could arouse or sustain. To be loved and accepted by YHWH and to know his favour means more than anything else could.
Maybe it's no coincidence that at this point "she stopped having children".