Currently,microsoftTeams.settings.registerOnRemoveHandler()is called whenever remove button is clicked. This is where you can do the clean up operation.
Know issue- User could possibly cancel the removal flow on feedback screen and there is no way to know that. We are working on the fix.
Currently, the workaround is to use Webhook 410 Gone response as the trigger to perform cleanup operations until the issue is fixed.
This known issue has been fixed. We no longer show feedback screen when user clicks on Remove for Connector. You can perform your cleanup operations on registerOnRemoveHandler()event and be sure that Connector has been removed.