Stability and symmetry breaking in the general two-Higgs-doublet model