Explicitly close sockets.

Change-Id: Ic3c91c6549a59ddf34eb92a8dcda912ac3d6af0c
Remove the temp directory after stopping daemon.

Every time the daemon is restarted we will get a new directory. Which is
probably highly desirable anyway.

Change-Id: I7f3f994b6f8e0fa02de1121e58914e05770033a4