When you delete a layer the drawing area is not refreshed and you can still see the entity in the drawing area.
Add a Refresh command after a delete layer comand
Add a Refresh command after a delete layer comand