On the closure of polynomials in weighted spaces of functions on the real line