In order to simulate observational and experimental situations, we consider a leak in the phase space of a chaotic dynamical system. We obtain an expression for the escape rate of the survival probability applying the theory of transient chaos. This expression improves previous estimates based on the properties of the closed system and explains dependencies on the position and size of the leak and on the initial ensemble. With a subtle choice of the initial ensemble, we obtain an equivalence to the classical problem of Poincaré recurrences in closed systems, which is treated in the same framework. Finally, we show how our results apply to weakly chaotic systems and justify a split of the invariant saddle in hyperbolic and nonhyperbolic components, related, respectively, to the intermediate exponential and asymptotic power-law decays of the survival probability.