There are a bunch of questions you need to be able to answer before you do something.
Why do you want the players to move slowly? Depending on the answer here, it may not even be an issue.
If it's because they're skipping all your well-designed encounters, there are a few ways to rectify things:
Design encounters for the route they take (this is primarily what has been suggested here).
Alternatively, you could just let them get to the town, complete the quest within 5 minutes, then tell them that you don't have any more prepared for today and bust out a board game.
If you wanted to not be a dick about it, you could take a moment and tell them that you've set the interesting encounters and adventures below ground. If they actually want to play the game, they should go after them down there.
If you want the players to move slowly because it gives you leeway to create more interesting and dangerous encounters, then you need to talk to your players and explain how teleportation and flight are making it difficult to design fun encounters for the game. Again, if you aren't playing with dicks, you can ask that they approach the game on a manageable level for you.
If they are dicks, then you might not need to be playing with them.
If you're able (and willing) to design fun encounters for the way they're approaching the game, and it's still frustrating you that they're hopping over your obstacles, be careful. You might be power-tripping.
Another thing to look at is why the players are trying to go that particular way.
If it's because they're concerned about how difficult the challenges might be underground, then feel free to use some of the suggestions here, and warn them (as you already have) that the challenges in space are not going to be any easier.
If they're trying to complete their quest most efficiently, then you can help your case by giving them a minimal amount of reward, and tossing a few, simple, go-here-kill-this quests their way to reinforce that combat is the primary source of XP and loot.
They might be looking for payouts other than leveling up and winning combat. If so, then you need to be careful with the group. D&D is a game where killing monsters and taking their stuff. If killing monster and taking their stuff isn't what they want to be doing, you may need to transition to a game that does what they want to do.
If they trust you to make the game fun for them, regardless of what they do, fantastic! You're already doing very well. Use the tips here to make your new battlegrounds and encounters and live up to their expectations.