Scripts/Commands: Fix issues reported by static analysis

Fix possible buffer overflow in ".server shutdown" and NULL-dereference/Triggered Debug Assert.