There's already an idea about a sleep timer here. Make sure to add your vote, since the more votes an idea gets, the more likely it is to be implemented. More info on how ideas work on Spotify can be found here.
In the meantime, and as @Sarahliz064 suggested, you can create a playlist with songs that amount to how long you want it to play. Just make sure you have Autoplay and Repeat turned off.