I just came across this problem and the evalDeferred doesn't work in all cases.
It seems like the least buggiest way to deal with deleting UI objects is just to not delete them.
use,
string $model_panel = modelPanel;
instead of,
modelPanel model_panel;
That way you don't run into the issue of duplicate named object errors.
Unless someone knows different?...