Great!...why did you put a the second battery on the load side of the inductor? Or did you simply mean the load resistance is shown as a battery (source)? So if your load resistance was too low it would drive you into the critical mode...
I have question about the second stage When the switch is opened the polarity of the inductor voltage is changed and the inductor becomes a voltage source , so the V out is equal to the inductor voltage in positive polarity. why did you use KVL in second stage as Vi is zero but we have new instantaneous voltage source by inductor ?