por los pelos[Espagnol]

nom
1 : something that barely avoids failure or disaster
2 : something achieved (or escaped) by a narrow margin