The ending works because the Soviets are allowed to believe the wrong thing: they think Red October was destroyed, and that belief is what lets Ramius and a few officers hand the submarine to the Americans. Ramius fakes a reactor emergency so his crew can be taken off, Loginov is killed trying to stop it, and the final maneuver at sea turns the attack back on the hunter, the pursuing Soviet attack submarine. Once the Soviet side writes the boat off, nobody is left to chase it.
Ryan and Ramius then bring Red October up the Penobscot River in Maine. Ryan flies home to London despite his fear of flying, which is a small joke, but it also tells you what the film thinks of him. In my opinion, the key point is that Ryan wins by reading a man's record and trusting his reading, long before he does anything physical. The earlier scenes set this up: Ryan studies Ramius's background, fails to convince his superiors, and only then flies out to the fleet and joins Commander Bart Mancuso aboard the USS Dallas. The argument comes first and the sea voyage second.
That is a different footing from the sequels. In Patriot Games, Harrison Ford's Ryan fights an attacker in London and is wounded doing it, so the danger is personal and physical. In Clear and Present Danger, he is acting deputy director of intelligence and does not know the President has quietly let his national security advisor start a covert campaign, so the threat sits inside his own government. In The Sum of All Fears, Ben Affleck's Ryan is a junior analyst brought in by CIA director William Cabot because of his research on the new Russian president, which is the closest echo of this film: an analyst whose job is to understand one man. Jack Ryan: Shadow Recruit goes the other way and makes him a Marine and Wall Street watcher before the plot starts. The film sets up Ryan as a capable field analyst, who later returns in other Jack Ryan stories.
The production backs up the reading. The US Navy supported the film after changes that portrayed the Navy favorably, supplying submarine access, the carrier Enterprise, the Houston, two frigates and helicopters, so the ships Ryan crosses to reach the Dallas are real hardware. John Milius also revised some scenes, including Connery's speeches and all of the Russian dialogue, which helps make Ramius feel like a man with a past rather than a defector in waiting. That being said, it is a quiet kind of victory, and I think it is why the film still holds up beside the louder entries.
For where this sits in the series, check Jack Ryan movies in order and the Jack Ryan timeline. The next story is Patriot Games.