Almost a masterpiece - frustrating writing/ending

Rating: 7/10 (6 November 2019)

This is an impressive horror movie with a lot going for it, but it is plagued by modern-day lazy writing which will frustrate a thinking audience. Lovers of this movie obviously haven't thought everything through as I will demonstrate below. And the slow-pace seemingly turned off a whole bunch of others, even though the superb gradually-building horror is one of its great strengths. The other impressive aspect is the acting, and this is universally acclaimed.
It's about a family plagued by disturbing horror that has made them thoroughly dysfunctional. One death after another, each surrounded by mysterious and strange details, and their lives are constantly made worse by spooky hauntings and strange behavior and events. Suspicions of insanity are conflated with supernatural horror.
The movie uses a heavy horror soundtrack and knows how to get under your skin using a mixture of classic horror and disturbing family drama and behavior. It does not resort to cheap jump-scares. (In fact, the movie could have been good even without the supernatural stuff by simply exploring insanity from trauma).
*major spoilers follow*
The one movie that this can be strongly compared to in terms of ideas and plot is Rosemary's Baby.
The stuff that is clearly thought-out:
Grandmother was obviously the leader of this cult that was trying to invoke Paimon in the bodies of her grandchildren. Presumably she wanted it done to her offspring for some reason, and they had to be young and 'vulnerable'. The previous attempt failed (Charlie) since she was female and they didn't know that this was important, and they had to kill her by invoking magic to undo it. There was also another failed attempt mentioned in the support meeting performed on Annie's brother. The rest of their efforts concentrated on Peter, whom they had to kill so that Paimon could take over his body. They even used and controlled her daughter (Annie) through 'sleepwalking' and possession to get their way, which is why she did all those strange and disturbing things to Peter.
Joan, a cult member, was pure manipulation to get their way through psychological trickery (rather than possession which wasn't working so far). The seance was a distraction just to get her to read the incantation and involve her family and to bring Paimon's spirit into the house by calling Charlie's spirit (which previously hosted Paimon). This worked and escalated the horrors since Paimon was now hanging around the family as a malicious spirit, and it even tried killing Peter in school on its own. So their goal was to kill Peter for Paimon who was only now ready to take him.
And now the stuff that wasn't thought through:

If all they needed was Peter to die, then why didn't any of the cult members simply kill him in his sleep or some other way after Annie read the incantation? They had free access to the house obviously as is made clear many times. And it didn't require magic since obviously suicide was enough. And it didn't require him being scared and vulnerable since he obviously was petrified many times beforehand.

If Annie had successfully burned Peter while 'sleepwalking' in the past, wouldn't this have deprived them of his body for Paimon? Plus, they hadn't yet released Paimon from Charlie at that time. So none of this sleepwalking stuff makes sense. Unless it was only her insanity added for random shock value.

What was the big deal with the book that she tried to burn? It's just stupid pictures. Why did she believe it would help in any way? And why did the father burn down instead of her even though she threw it in the flames? Why did anyone burn at all? Either the book is meaningless in which case her motivation has no logic, or it is meaningful and yet it had no effect except to burn random people. 'Random malicious games by an evil spirit' doesn't explain why she was obsessed with the book to begin with while she was awake.

What was the point of having Annie decapitate herself at that point towards the end? She was a useful tool until then and still hadn't achieved her purpose. So one can't even attribute this to 'random evil' from a being that likes decapitating people, since it's against their own interests. I mean they obviously were desperately trying to have her kill Peter until now and he still wasn't dead. In fact, what killed him was his own suicide from the surprise-shock of the three naked cult members after that. Which, once again, seems completely random and this from a cult that otherwise made careful plans. Inconsistencies galore!

What's the point of the headless corpses? They were obviously dead since besides being headless, they were also decomposing and not moving. So why would the cult bother bringing them into the house and have them bow down in the final scene? Just more pointless shock tactics for the audience rather than the plot.

In summary: The atmosphere and acting get 9 or even 10. The writing gets 8 or 1 depending on specific aspects of the plot. The problem is that the movie is effectively disturbing and seems like a great horror movie for most of its running time, except that the ending leaves you with unanswerable questions that don't allow the movie to make any sense. It's not just full of random malicious acts, it's also inconsistent with clearly stated motivations. So the frustration trumps the movie. This is a trend with recent horror movies that string together a bunch of creepy or shocking scenes for their own sake without tying them to the plot, or even working out whether they contradict the plot.