A ring resonator can be treated as a universal model of a looped dynamics in a Hilbert space. A particular example of a loop occurs in the problem of time travel in space-times whose topologies allow for closed timelike curves (CTCs). I generalize the ring-cavity formalism to an abstract Hilbert-space level. I show that it automatically removes logical inconsistencies associated with chronology protection, provided all input-output relations are given by unitary maps. Examples of elementary loops and a two-loop time machine illustrate the construction. The general formulas, when applied optical ring resonators, reconstruct the quantum optical results and thus agree with experiment. However, the resulting treatment of CTCs is not equivalent to the one proposed by Deutsch in his classic paper.