The inductor needs to discharge through some path. Your switch symbol appears to charge the inductor only. You need to provide another section of the circuit which discharges the inductor.
In real life, an inductor generates a voltage spike when it is conducting current, and you open the circuit suddenly. The spike can be so severe that is causes a spark.