You can resign but have to serve your notice period. After that you will have to go back to your home country.