Writhe, agonize, squirm are comparable when they mean to twist or turn in physical or mental distress.
Writhe regularly carries vivid suggestions of convulsive contortions (as of one in the throes of death, in a paroxysm, in an instrument of torture, or in a trap) and of fruitless struggling to escape. When used in reference to physical distress, it commonly implies also great pain. When extended to refer to mental distress, it usually implies a torturing sense of shame, of bafflement, or of frustration.
Agonize sometimes evokes the image of one in the pangs of death, struggling and in anguish; sometimes it evokes the picture of one wrestling or straining arduously to achieve a difficult victory.
Squirm evokes images of a less dignified or a more familiar character; it usually does not imply profound distress, but great unease (as in aversion to restraint or discipline) or a shrinking or wincing (as under sarcasm or criticism).