In this paper we establish the necessary and sufficient criterion for the contact process on Galton-Watson trees (resp., random graphs) to exhibit the phase of extinction (resp., short survival). We prove that the survival threshold lambda(1) for a Galton-Watson tree is strictly positive if and only if its offspring distribution xi has an exponential tail, that is, Ee(c xi) < infinity for some c > 0, settling a conjecture by Huang and Durrett (2018). On the random graph with degree distribution mu, we show that if mu has an exponential tail, then for small enough lambda the contact process with the all-infected initial condition survives for n(1+o(1))-time whp (short survival), while for large enough lambda it runs over e(Theta(n))-time whp (long survival). When mu is subexponential, we prove that the contact process whp displays long survival for any fixed lambda > 0.