I would say that it is not true that quotients of polynomials rings are "almost UFDs".

For starters, being a quotient of $k[x_1,\ldots,x_n]$ for some $n$ just says that the ring is finitely generated over $k$. If $k$ is a field these rings are reasonably nice but they can still be quite "badly behaved" and a long way away from having unique factorization.

For instance one can view the class group of a Dedekind domain $A$ as measuring how badly unique factorization fails in $A$. This group can be very large even when $A$ is finitely generated over a field - taking the ring corresponding to an elliptic curve with a point deleted gives examples with infinite class group (the class group is pretty much the underlying elliptic curve in this case).

In fact it is a theorem of Claborn that any abelian group occurs as the class group of some Dedekind domain. I am not sure how far one can get working with finitely generated algebras over a field, although there are other results in this direction that allow one to construct such examples by taking integral closures in quadratic extensions I think, or via rings of functions on elliptic curves (this second being work of Rosen originally).

And all of this is just in dimension 1.

I understand the other part of your question now and I like Ben's answer. In higher dimension trying to understand this will get worse - I think about the best general statement one can make about unique factorization is that every regular local ring is a UFD so if the geometric incarnation of your algebra is singularity free it is locally a UFD.