Ensures resources are released