is there a way to destroy a struct attached via SetUnitUserData() after it dies? I tried

JASS:
function SomeFunction takes nothing returns nothing
local unit killed = GetTriggerUnit()
local mobdata mobd = GetUnitUserData(killed)
call mobd.destroy()
but Grimoire gave me "attempt to destroy null struct of type" error. Any way around this? or am I going to have to use CSData?