Why this optoisolator triac (MOC3021) using for DC/DC switching is not turing off?
If TRIACs have a minimal latching current going through them, they will stay on even after gate current has been removed - so with DC until the 12VDC switches off.

You need to use a transistor output optocoupler, such as 4N25, 817, etc. They are cheap and easy to find.