Establish If It's A Problem
I get it. You're the GM and you're trying to get something done, and people are going on 10 minute long diatribes about Rogue One during a villain's monologue. But — some people, and some groups, want different things out of gaming. For some folks, getting together and talking geek is the point, and the game is just something else you're doing as a backdrop.
I wrote a blog post comparing RPGs to sports, and in sports you have local pick-up games, league games, etc. And different levels of engagement are expected in them. Some folks are just there to mess around, not to play seriously. And that's valid, even if it's not what you want to do.
But on the other hand, this can verge over into just being plain rude. If you were playing poker or Xbox or basketball or Uno or anything else in the world and someone interrupted play to jibber jabber for that long someone would tell them to shut the heck up and take their turn. Gamers are sometimes not super high on the social skills/cues end of the spectrum and, regardless of how "serious" the game is, can be engaging in behavior distracting in any other situation.
What you want to do is get group buy-in on what you're doing and what the general tone of the game is. But if in general everyone in the group is happy with the current mode of operation, it may be you that has to change. You don't have to accept pure-play rudeness — if someone interrupts what you're doing, especially as the GM, get over the geek social fallacies and call them out. "Hey Beavis I was talking, simmer the hell down." But some groups play games as an excuse to come together and geek talk for 6 hours, and if you want something different you may have to switch/cull groups.
For a while, I was a single dad who had to pay a babysitter for my once-every-two-weeks break, and I wanted to spend it gaming. I certainly looked for a group that spent their time on task; I don't need to pay $20/hour to listen to some fatbeard talk about George Lucas; I can get that for free on the Internet at home. It's fine for you to want that too, you just have to understand that you may want something different and valid from what the others in the group want. Get that hashed out.
Fix What's Wrong
If you can get the group to generally say "Oh OK, we should probably stay a little more on task during the game, some people are here to play the game and not just chat, fair enough" then you can do a couple things.
First, take breaks. I ran a super serious "everything is in character" campaign for years, and I'd run for 45 minutes and take 15 minute breaks, so people could get the talking (and snacking and whatnot) out of their system. If you try to bull through 4 hours without distraction you're always going to be disappointed.
Second, maybe divide groups. To run that serious campaign, I had to take a large group and split it into a "funsies group" and a group of people willing to accept a less screwing-around premise.
Third, do other smart logistics things like have the group get together for lunch beforehand to get some of the jabber out of their system.
Fourth, if you're running the game, you can simply start enforcing a variety of moves — like "What do you do?" "Well if this were Deadpool I'd blah blah..." "Ok, you spend your turn engaged in fantasies. Next player in the initiative order, what do you do?" Or a variant on that, insist on things being in character — random joking and blathering will bother the NPCs, give you away to the monsters, etc. Just keep running the game, and those not participating will miss out. Again you need buyin for this to not backfire, but it's fine to do. Force action in-game. Interrupt the misbehaving dialogue with "an orc shoots you with a crossbow!"
Fifth — general small group skills. There's any number of articles on the internet about small group behavior/small group discussion that you can learn techniques from that are useful in leading any small group and keeping them on task. Stress goals, redirect disruption, basic management/meeting facilitation skills. These are out of scope of this SE but there's plenty out there to learn (bonus: helps you in management, teaching, etc. in other parts of life).