Regular cleaning and maintenance
The biggest issue that makes doors prone to coming off the tracks is lack of maintenance. Sliding glass doors, like all the other parts and systems in your home, require regular cleaning and maintenance.
Most people only clean the glass. Sure, that’s the obvious part that gets dirty, but so do the tracks and wheels. So when was the last time you cleaned them? When the wheels and track are clean and clear of debris, they glide easily together. But add in some dirt, dust and debris and the wheels don’t roll quite so easily. After a while the wheels don’t just not roll and glide, they completely stop moving. Now that’s a problem!
So the first step is to make sure that doesn’t happen. Each time you clean that glass be sure to check the tracks for dirt and debris. Use your vacuum to get most of it, then use a brush, rag and spray cleaner to finish the job. If you see anything stuck to the wheels, clean them as well. Don’t forget the top tracks and wheels as well. They can have debris like cobwebs and such too. Clean tracks and wheels don’t usually get stuck or hard to open and close! Then be sure to lubricate them.
There is other periodic maintenance that needs to happen
Every six months or so you should tighten the screws on the track. If the screws are loose, they can block the path of the door, so don’t let your doors have a screw loose! Then use a brush to clean the small drain holes along the side of the track that are there to let water escape. If they are clogged they can also block the path of the wheels. If you do this, you shouldn’t have any trouble. If there is, you can also adjust the door height by turning the screws on the side of the door.
Rollers are made of nylon and will dry out and crack with age.
Do not oil them: this will only attract dirt to both rollers and tracks. Instead give them a good wash with hot soapy water. Replace rollers as soon as you notice any problems with them - continued use of damaged rollers will cause irreparable damage to the track.