We study production networks where firms' products can be described by a set of input and output characteristics, and links are formed only if the output characteristics of a seller match the input characteristics of a customer. We introduce a fully endogenous network formation model with monopolistically competitive firms, in which firms exit due to exogenous shocks, or the propagation of shocks through the network. Firms can replace suppliers they have lost due to exit subject to switching costs and search frictions. This enables us to study the impact of shocks on aggregate production in an adaptive network, and we show that depending on the nature of the shocks, adaptivity can make the network more or less stable. We then evaluate the output loss due to the exit of a firm, and apply our model to a novel international production network dataset.