Cleanup in terminate func.