There are two steps to set up this feature so that you only ship to certain locations.

Step 1. Go to "Settings"->"Localisation"->"Geo Zones". Click on "+" icon to create a geo zone. 

Step 2. Name the Geo Zone. Click on "Add Geo Zone" to add the geo zones
in which you want to sell your products. Do not forget to click on "Save" icon to save the changes. 

Step 3. Go to Settings->General->Advanced->Order Options to choose the 'Only Ship To' geo zone and input your notification message that will show when customers from other geo zones try to purchase products from your store. 

Customers from outside the geo zones you set won't be able to checkout and will get the notification message you wrote.