Remove the mapped domain by code

HI,
all my sites are domain mapped.
i want to remove the mapped domain by code when the pro status is "remove" (over).
please provide some code for that task.

Thanks