Clean up pin/unpin for sockets and other types of handles.