Why Stock Markets Crash: Critical Events in Complex Financial Systems