[minor] fix agent id retrieval in socket
[minor] simplify agent shutdown during package install