Check if this code sample can help:
How to make FoxPro application automatically close all documents and programs it startedhttp://www.news2news.com/vfp/?example=491The idea is that when opened, a document or file is linked to a special system entity called "job object". Closing a job object automatically closes all documents linked to it.
This code sample opens file using the CreateProcess API rather that ShellExecute.