Hello, Alejandro. Usually, "deleted in a bad way from the Gateway" means that the API the gateway was deleted first without following the documented process for removing an API from the portal first (Remove APIs - CA API Developer Portal - 3.1 - CA Technologies Documentation). When this happens, as you've found out, there are usually dangling references in the portal.
Note, some things are left alone on purpose for historical reasons (e.g. analytics, forums, etc.), but some customers would still like to get rid of those things sometimes.
To remove a left over documentation page, you can do this by navigating to the page in the portal instance's staging environment and deleting it. For example, if I needed to do this for my Math API:
To remove a left over forum, you can do this through the forum's admin control panel:
To remove the API from other selection lists, for example:
You must navigate to the portal's underlying admin interface ("/admin" on your portal, e.g. http://yourportal/admin), go to content items, and find and remove the file that corresponds to your API (Make sure it's the right file corresponding to the deleted API ID, and not just having the same name as the deleted API):