Risk, External Adjustment, and Capital Flows