It's an old book about this thing controlling humans and making them do everything in the same set of patterns and actions, until someone tries to break free and destroy it.
Possibly A Wrinkle in Time, by Madeleine L'Engle. The characters travel (via tesseract) through several dimensions, one of which is controlled by IT - a shadowy, disembodied brain that makes everyone behave identically. For instance, children bouncing balls on the sidewalk in rhythm. When one child makes a mistake, he's taken off and punished.
IT doesn't get destroyed in the book, though. Instead, the main character, Meg, rescues her brother, Charles Wallace, from IT's influence and they escape the planet.