The two are mosty unrelated - you are under contract for as long as you are under contract, whether you are on the 40-man or not, and whether you are in the majors or not. That said, there are some roster rules, designed to protect players, that might come into play. For example, you can only be removed from the 40-man roster once against your consent. If they try to remove you a second time and you clear waivers, you can elect to become a free agent at that time.