There is no built-in option to do this, but there are several third party apps that are made for your situation.

This one that does exactly what you asked (and more).

Basically, it lets you set a number of tracks to play, amount of time, or entire playlist to play before performing a set action (shut down, sleep, pause, etc.).

If you're looking for a free version, there are two options that are timers only (set them to the length of your song to play just one more).

This is an AppleScript that lets you very simply launch it and enter a number of second to continue playing for.

This is a dashboard widget that lets you drag a slider to set the time to continue playing for.