Pressure/Voltage analogy
Like most analogies, there are some differences, but, yes,
closing a valve CAN cause a buildup of voltage; that's how
an automobile spark coil operates.   The trick is sometimes known
as 'flyback', and is an important way to produce high voltages.

So, the difference starts with hydraulic 'closing a valve' becoming
electrical 'opening a switch'.   Both mean that one impedes the flow.   It continues
with 'pump causing pressure to rise' being replaced with
'inductive kick' which is similar to using a mass of
moving water to lift some of that water to a high elevation.
That difference is because most electrical current sources do not
ignore back-voltage, a battery simply ceases to supply
current when you turn a flashlight off (but adding a magnetizable
element, an inductor, changes that equation).

The equations that describe an inductor (aka coil or electromagnet)
are equivalent to giving a momentum term to the slow-moving current of
nearly-massless electrons.

And finally, the 'breakage of a pipe' becomes the breakage that
occurs with high voltage, the breakdown of insulation (and 
across the insulating electrode gap of a spark plug, fires the internal
combustion that makes your car go).