diff --git a/lib/factorio/server.js b/lib/factorio/server.js index d05cf4f3..afae615d 100644 --- a/lib/factorio/server.js +++ b/lib/factorio/server.js @@ -620,6 +620,13 @@ class FactorioServer extends events.EventEmitter { this._state = "stopping"; if (this._rconClient) { + + // If RCON is not yet fully connected that operation needs to + // complete before the RCON connection can be closed cleanly. + if (!this._rconReady) { + await events.once(this, 'rcon-ready'); + } + await this._rconClient.end(); }