PWM controlled MOSFET based DC motor driver, stuck with reverseing direction
The reason you see the sparks is because you are open-circuiting a charged inductor (ie the stator of the motor) 

Thou shall not open-circuit a charged inductor, thou shall not short-circuit a charged capacitor.  

The stator of the motor has been "charged"... you have at one point applied a voltage to it to permit current to flow. For whatever reason (intent or oversight...) the relay has opened the stator terminals. The inductor MUST keep the current flowing &amp; due to: \$V = L\frac{dI}{dt}\$, a sudden (attempted) change in current can only result in an increase in voltage which leads to sparks, avalanche or insulation breakdown. 

To remove such sparks you could consider using a H-Bridge arrangement but these are more involved.  As a "poor mans" replacement, some sort of snubber across the motor would be the next best thing. An R-C-Z would be one option