I'm having some trouble figuring out what happens in the above reaction. Based on the strongly basic conditions I think that a benzyne mechanism should be operative, but I'm not sure what else should happen, or whether the nitrile is involved in the reaction. What is the product and how is it obtained?
You are correct that a benzyne is formed as an intermediate in this reaction. However, the nitrile is not an innocent bystander. Recall that protons α to a nitrile group are acidic: this is because the negative charge can be delocalised onto nitrogen. The pKa of a typical nitrile is around 30, lower than that of ammonia, which is roughly 40 (see: Evans pKa table). So, sodium amide is capable of deprotonating α to the nitrile.
This anion can now act as a nucleophile in the benzyne mechanism which you are no doubt familiar with. Note that the intramolecular attack of this nucleophile is likely to outcompete intermolecular attack of the amide ion. Also, since the nucleophile must attack intramolecularly, there is no question about which triply bonded carbon it attacks; it can only reach the position ortho to itself:
This specific reaction to form a benzocyclobutene is described in, for example, J. Med. Chem. 1966, 9 (5), 656–659.