add instance cleanup for the api