i can close document with AppleScript,like:
tell application "Numbers"
close every document without saving
I don't think you can do it - at least via a pure Swift solution. Swift is a language, and an open source one at that. It now is run on servers and on Linux-based machines. In the Apple ecosystem, it also can be used on all iOS devices - including Apple TV and Apple Watch.
Closing or shutting down an app is the responsibility of the OS, not a language feature. If you want a way to do it in macOS, you probably are best to write that AppleScript command file and kick it off using Swift.