The film is as masterclass in suspense, disturbing imagery, acting, and cinematography. It's an extremely well crafted film and some moments really stuck with me.
Having said all that, I found the very last scene to be rather baffling and I still don't fully understand it. I don't expect a movie to spell things out for me but thematically I don't see how the implications of the ending connect with the rest of the film. Other than "grandma was into some cult shit".
A quick overview but the general gist of the storyline:
The grandma and the cult she was in were meant to find a vessel for Paimon (the demon that takes over Peter's body at the end). Paimon needed a male vessel but they were temporarily using Charlie as a vessel until they could get a male host for him.
Annie knew that something was weird about her mother, throughout the movie she talks about how she didn't want her mother around Peter, as well as her late brother (who had committed suicide), who said that they were trying to put "people" inside him among other strange things her mother did.
Joan (Ann Dowd, the woman that Annie strikes up a friendship with that she doesn't realize at first was in the cult with her grandmother) is teaching her "rituals" that Annie thinks are meant to help her, but they aren't, they are rituals that is allowing Paimon influence over her and Peter.
After Charlie dies and Annie has Peter do these rituals Paimon is able to enter Peter because of this, however Peter still has some control. Once he jumps out of the window (and dies) this allows Paimon to then fully take over his body and he now has the male vessel that he needed to come fourth fully and have his power.
Throughout the movie you can see members of this cult in the background, around the house, in dark corners of the rooms, they are literally ALWAYS watching Annie and the family, influencing them, and paving the way for Paimon to take over Peter.