Tens of thousands ordered to safety in France and Spain as Madrid declares national emergency