Space is often used as an example of a vacuum, but it is not a perfect one. Lets take the example of the earth's atmosphere. The highest level of the atmosphere is known as the Exosphere. Here molecules are constantly exiting (and re-entering) the atmosphere. This is the same for planets (with an atmosphere) across the universe.