Hydraulic shock AKA water hammer....(wiki link)
The second scenario is because the pressure rises rapidly when the solenoids close.
You have two choices, add a commercial water hammer arrestor or do it the way they did in the old days, build an air gap into the system. I couldn't find a...