There's a reason that virtually all growth happens before the end of adolescence. At either end of your long bones are areas of tissue known as epiphyseal plates, or "growth plates." These plates are soft and flexible during childhood and adolescence, allowing the surrounding bones to grow. At some point during adolescence, though, the growth plates harden, and growth is essentially finished.
However, adults lose on average between one and two inches of height due to hunching, poor posture, and inelastic disks in the spine. While no more new growth will occur at age 40, you can recover this lost height.
Stretch every day for 5 minutes. Loosening up your back muscles will improve your posture, which will add slightly to your height and also make you appear taller. Lying on your back on the floor, pull one knee at a time slowly to your chest and hold it there for 10 seconds. Then, keeping your feet flat on the floor with your knees bent, lean your knees as far as you can to one side and then the other. These and other stretches can help keep you loose.
Try yoga or pilates. There is a good deal of anecdotal evidence that these exercises can improve your spinal health and, by straightening out your spinal column, increase your height. A studio in your area may offer yoga or pilates classes, or you may prefer a video or on-line program to guide you in a home exercise program.
Consult a chiropractor, who may measure your posture through simple observation or with more complicated tests such as inclinometry and posture guides, and may administer muscle and joint flexibility tests to determine how loose your joints are. The chiropractor may then perform a spinal alignment on you, or may simply use heat, massage, stretching and exercises to try to correct any posture problems. The improved posture that may result from a visit to the chiropractor can give you an inch or two of regained height.
Maintain overall bone health to keep your spinal column from deteriorating. At age 40, you should consume at least 1000 milligrams of calcium a day, and engage in weight-bearing physical activity like jogging, tennis, stair climbing or weight lifting at least two or three times a week. This will help prevent future height loss from hunching and osteoporosis.