Revelation 12:7-9 shows the demons cast down, and when that occurred, this earth became their prison. Job 1:6-7 describes Satan as free to walk back and forth on it. It is not said that every demon spirit has that liberty; they may or they may not. Nevertheless, they are able to be restrained.