The paper studies the dynamics near periodic orbits in dynamical systems with relays (switches) that switch only after a fixed delay. As a motivating application, we study the problem of stabilizing an unstable equilibrium by feedback control in the presence of a delay in the control loop. We show that saddle-type equilibria can be stabilized to a periodic orbit by a switch even if this switch is subject to an arbitrarily large delay. This is in contrast to linear static feedback control, which fails when the delay is larger than a problem-dependent critical value. Our analysis is based on the reduction of the return map near a generic periodic orbit to a finite-dimensional map. This map is smooth if the periodic orbit satisfies two genericity conditions. A violation of any of these two conditions causes a discontinuity-induced bifurcation of the periodic orbit. We derive asymptotic formulas for the piecewise smooth return map for each of these two codimension-one bifurcations. This analysis shows that the introduction of a small delay into the switching decision can induce chaos in a relay system that had a single stable periodic orbit without delay. This small-delay behaviour is fundamentally different from smooth dynamical systems.