Does the script step "Close File" not work for you? Also, have you looked at one of the syncing solutions like GoZync, MirrorSync, Easy Sync?
If your local file has any table occurrences (TOs) that link to the server file, then the server file will remain open. What you'll likely need to do is deploy a connector file (from a container field in the local file) that has the TOs to the server file. Remove any TOs to the server file from the local file, and run your import / upload routine from the connector file. When complete, close the server file and then the connector file. This will close the server file and leave it closed.