The Swift runtime uses its own mechanism to manage the lifetime of the process. Unfortunately, main.swift does not yet support async code, but I would generally recommend using an @main type with an async main function, instead of trying to do your own synchronization. I believe swiftpm should support executables that use @main instead of main.swift now.