Use your edges to set (front foot inside edge...tip up for frontside spins, tip down for blindside spins). Also, open or close your shoulders, depending on which way you want to spin out, while you're on the rail.
If you want to spin frontside, dig your front foot inside edge into the rail with the tips up (so almost slide the rail with your heel on your front foot), and point your shoulders and chest towards the end of the rail, while you leave your trailing arm dropped back (so if you slide right foot forward, your left arm gets kind of dropped back), then when you get to the end of the rail, pop or jump (don't just drop off the rail) and start to spin. Now while your in the air you need to spot your landing, for front 2s out you want to look back up hill and land switch. While you're on the rail you should look something like this:
If you want to spin blindside, dig your front foot inside edge inot the rail with the tips down (so you're sliding more with your toes), and close your shoulders and chest off to the end of the rail (so your chest kinda faces back up hill towards the beginning of the rail) with your front arm left out pointing towards the end of the rail, then when you get to the end of the rail (again) pop or jump and start to spin. Now while your in the air you want to spot your landing, for blind 2s out you want to look back down hill and land forward. While your on the rail you should look something like this:
After you get 2s out, bigger spins just require more grip, a harder set, and to keep looking and spot later. Hope that helps, good luck.