Flyback Diodes For Inductive Loads With Long Wire Runs
To draw the circuit with some extra stray components







simulate this circuit &ndash; Schematic created using CircuitLab

Only D1 is necessary.

D2 can only control the kickback from L1. The kickback from L2 is not controlled by D2. If L2 is large enough, if there's enough wire or it runs in a loop rather than as a pair twisted with its return, then there could be enough energy stored in L2 to concern Q1. 

Solenoids are often sold with D2 incorporated, to simplify the circuit. It doesn't hurt to have both D1 and D2, as it affords some measure of redundancy.

Some FETs have an 'unclamped avalanche' rating, for use as solenoid drivers without D1. They will safely take a specified kickback energy without failing. This is rarely the case for BJTs.