Install a shock asorber or an APPROVED type serviceable air chamber to allow the shock wave from the quick closing solenoid valve to dissipate, as these shock waves if allowed to go unchecked will rupture a line.
Water hammer is a very can be a dangerious condition.