There is growing consensus that processes of market integration and risk diversification may come at the price of more systemic risk. Indeed, financial institutions are interconnected in a network of contracts where distress can either be amplified or dampened. However, a mathematical understanding of instability in relation to the network topology is still lacking. In a model financial network, we show that the origin of instability resides in the presence of specific types of cyclical structures, regardless of many of the details of the distress propagation mechanism. In particular, we show the existence of trajectories in the space of graphs along which a complex network turns from stable to unstable, although at each point along the trajectory its nodes satisfy constraints that would apparently make them individually stable. In the financial context, our findings have important implications for policies aimed at increasing financial stability. We illustrate the propositions on a sample dataset for the top 50 EU listed banks between 2008 and 2013. More in general, our results shed light on previous findings on the instability of model ecosystems and are relevant for a broad class of dynamical processes on complex networks.