Please be aware of the Forum Rules of Conduct.
Do you still have an estate in the city you were lord of?
Leave it, then appoint yourself Duke.
Please report this as a bug. As ruler, you should have had your estate vacated as well, by the cleanup script.Also, if you lost your position as duke and margrave, how did you keep ruler? You should have lost that, too.
IIRC the abdication period for ruler is shorter than that for lordships. If you got kicked out of Duke/Lord (7 days), you should have lost ruler (5 days).