Cleanup references on shutdown