Whomever does the most damage to the flag ship gets boarding rights, so even if you're swarmed by "the fleas", they probably won't damage the flag enough to get the right to grapple it. If the little green circles pop up after you hit it, the ship is yours. I agree that it's truely annoying to try to take down a ship whilst the little guys are firing off cannons all over the place, but no other pirate can grapple "your" ship.
On a side, you can still get a stowaway during the process. If someone is close enough to your ship to click on your pirate, they can TP to you, and therefore be on your ship while you are grappeling the flag. Which means they can board that flag with you and loot your booty. According to the latest updates, this "feature" will be gone with soon. I hope so!