How long can you live with gastric cancer in 4th stage, if it has spread to liver, lungs, and pancreas?

Not long. The prognosis is very poor, however life expectancy is ver hard for docs to predict. Life span will depend on responsiveness to treatment and performance status of the patient, but with disease like you describe, I would e pect 6 months or less.
Unfortunate. The prognosis for this instance is very poor, I'm afraid. It would be weeks to a few months I'm guessing. Sorry.
Limited survival. Gastric adenocarcinoma that is widely metastatic to other organs is a very difficult problem. Generally, these patients have a limited survival which is usually measured in months.