One of the many meanings of to stop is “to dam, to plug up,” as in “to stop a leak,” or “to stop a drain.”
And a stopgap, even in its modern sense of some temporary measure to fill a need, is, both literally and figuratively, something to “stop” a “gap.”