Skip to content

Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.

stopSteam returns at once when no Steam client runs: steam.exe -shutdown booted a whole client only to close it, 15 to 45 s on every first Play with a fix that changes the launch environment (Forza Horizon 6 pass on the M4, 2026-10-06)

Gauthier Piarrettedd2c99c7116f
diff --git a/Sources/HighballKit/SteamRestart.swift b/Sources/HighballKit/SteamRestart.swift
index 04d411f..88d4988 100644
--- a/Sources/HighballKit/SteamRestart.swift
+++ b/Sources/HighballKit/SteamRestart.swift
@@ -165,7 +165,11 @@ extension WineRunner {
/// client (highball#152: launching a second program ended the first). Steam's own
/// `-shutdown` closes the client cleanly; when it does not go within thirty seconds, its
/// processes alone are signalled. Games and other programs keep running throughout.
+ /// With no client running there is nothing to stop: `steam.exe -shutdown` would boot a whole
+ /// client, web helper and all, only to close it again, 15 to 45 seconds on every first Play
+ /// with a fix that changes the launch environment (measured on an M4, 2026-10-06).
public func stopSteam() async throws {
+ guard steamIsRunning() else { return }
let steam = bottle.driveC.appending(path: "Program Files (x86)/Steam/steam.exe")
_ = try? await run([steam.path, "-shutdown"], renderer: nil, label: "steam-shutdown")
for _ in 0..<300 where runningSteamEnvironment() != nil { try await Task.sleep(for: .milliseconds(100)) }
diff --git a/Tests/HighballKitTests/SteamStopTests.swift b/Tests/HighballKitTests/SteamStopTests.swift
new file mode 100644
index 0000000..d5fe771
--- /dev/null
+++ b/Tests/HighballKitTests/SteamStopTests.swift
@@ -0,0 +1,25 @@
+import XCTest
+@testable import HighballKit
+
+/// Stopping Steam where none runs must not start one (gin-64's Forza Horizon 6 pass, 2026-10-06:
+/// `steam.exe -shutdown` booted a client and the launch came 46 s later).
+final class SteamStopTests: XCTestCase {
+ func testStoppingSteamWhereNoneRunsStartsNothing() async throws {
+ let root = FileManager.default.temporaryDirectory.appending(path: "hb-steamstop-\(UUID().uuidString)")
+ addTeardownBlock { try? FileManager.default.removeItem(at: root) }
+ let paths = HighballPaths(home: root.appending(path: "home"))
+ let bottleURL = root.appending(path: "bottles/quiet")
+ try FileManager.default.createDirectory(at: bottleURL.appending(path: "drive_c/Program Files (x86)/Steam"), withIntermediateDirectories: true)
+ try Data().write(to: bottleURL.appending(path: "drive_c/Program Files (x86)/Steam/steam.exe"))
+ let bottle = Bottle(url: bottleURL, settings: BottleSettings(name: "quiet", engineID: "x64-test-r1"))
+ let engine = InstalledEngine(manifest: EngineManifest(id: "x64-test-r1", displayName: "test", arch: "x86_64", minMacOS: "14.0", components: [:]),
+ root: root.appending(path: "engine"))
+ let runner = WineRunner(paths: paths, engine: engine, bottle: bottle)
+ XCTAssertFalse(runner.steamIsRunning())
+ let start = Date()
+ try await runner.stopSteam()
+ XCTAssertLessThan(Date().timeIntervalSince(start), 2)
+ let logs = (try? FileManager.default.contentsOfDirectory(atPath: paths.logs.path)) ?? []
+ XCTAssertFalse(logs.contains { $0.contains("steam-shutdown") }, "no steam.exe -shutdown run when no client runs")
+ }
+}