Both RatherBBurnin and Dewayne are correct. However, I'll add just a little bit more to it.
You can top as soon as the plant has alternating nodes. That's the sign that the plant is sexually mature. You shouldn't top prior to then.
You can also start LST. That will re-direct the plant growth sideways instead of upwards. Keeping them as small as you would like will be difficult. MJ just likes to be much taller than that. You might instead, think of modifying your grow area to accommodate a taller plant.
It's kind of like someone saying "I want to grow my plant in a shoebox." That would be impossible. Sometimes you have to do what the plant requires, not what you've limited it to. Trying to make a plant that naturally grows up to 20 feet tall, grow in a 12 inch area isn't good planning.
Good luck to you.