It'd be useful to have an API to register cleanups after test, profile and execution which we'd simply register before allocating such resource and might re-use it for other tests/profiles. We might inspire from Avocado's CallbackRegister class https://github.com/avocado-framework/avocado/blob/master/avocado/utils/data_structures.py#L189