kill app in a given timeframe, bash script

I'm new at bash and I am trying to make this, here is a pseudo code:

id= "pidof rhytmbox" (rhytmbox changes pid everytime i start it)

echo "Input time: "
read time

sleep $time
kill $pid

can you assist me?


pid=$(pidof rhythmbox)
echo $pid

echo "Enter time: "
read time
sleep $time
kill $pid

This one worked!