Cleanup more before exiting.

This closes some sockets and frees protocol memory.