Wikipedia gives the details of how the Borg are destroyed.
I found a reference that the Borg were chasing Voyager with an entry open and overtook it as they reached the Alpha quadrant. While the Borg were fighting the fleet, Voyager launched torpedoes from inside. The following from the script gives the implication, however I do not have the novel reference
(The Sphere prepares to activate its tractor beam.)
PARIS: I can't stay ahead of them, Captain.
JANEWAY: Mister Paris, prepare to adjust your heading.
PARIS: Yes, ma'am.
This implies that the script statement means that they realize that the sphere will pull them in and will be vulnerable to the torpedoes.
Memory Alpha Wiki hints the same thing but deliberately obfuscates the description.
Endgame (Star Trek: Voyager)
Meanwhile Captain Janeway and her crew have entered a transwarp
corridor and fire torpedoes at the unprotected manifolds while
traveling back to the Alpha Quadrant, but are pursued by a Borg sphere
that has managed to withstand the pathogen's effects and assimilate
Admiral Janeway's adaptive armor upgrade. It is now following the Borg
Queen's final orders to destroy Voyager so that the Admiral (and her
sabotage) will never exist. Unable to fight back against the ship's
exterior defenses, Janeway takes her ship inside the sphere, where,
upon its arrival one lightyear away from Earth's solar system, she
detonates a torpedo that destroys the sphere from the inside.
In the show's final minutes, the crew stand dumbfounded that they have
finally returned home after seven years lost in the Delta Quadrant and
are greeted by a fleet of Starfleet vessels which had arrived to fight
the Borg. Settling down in her chair, Captain Janeway issues her final
orders with the same words she used at the start of Voyager's journey:
"Set a course...for home."