It is just the way Rowling always planned it (for the main series at least)
Richard: I was dodging around the death bit, because I know you can't answer that question, But you know how Conan-Doyle got sick up to there of Sherlock Holmes ...
Richard: ... so pushed him off the cliff at the Reichenbech falls, I'm not asking if you have done that obviously, but have you ever been tempted to bump him off because it is such a huge thing in your life.
Jo: I've never been tempted to kill him off before the end of book 7. I have always planned seven books and that is where I want to go, where I want to finish on seven books. But I can completely understand the mentality of an author who thinks "Well I am going to kill them off because that means there can be no non-author written sequels as they call them, so it will end with me and after I am dead and gone" - they would be able to bring back the character and write a load of ...
She also planned the ending from the very beginning:
Jo: No, the last book is not finished, though I am well into it now.
Richard: But you have written the finale already?
Jo: I wrote the final chapter in something like 1990? - oh hang on - I wrote the final chapter in something like 1990.
26 June 2006 - Richard and Judy Show, Channel Four Corporation (UK)
In the end you also have to consider her target audience was children and young adults. The books did "grow" with the reader as each installment became a bit more mature. However, even Rowling being such a great planner it is very difficult to plan an indefinite story. The story has grown over the years with the Cursed Child, Fantastic Beasts series, and numerous other short writings on Pottermore. You have to account for what the creator wants to do, go where they want the story to go...