I use an app called "Opal" for my camera that constantly freezes on me which I need to manually quit then re-open. This script does it all for me:

Open restart-opal in Script Kit

// Name: Restart Opal
import "@johnlindquist/kit"
let fkill = await npm("fkill")
let open = await npm("open")
let app = "Opal"
console.log(`Closing Opal`)
try {
fkill(app, { silent: true })
} catch {
console.log(`Wasn't running...`)
}
await wait(1000)
console.log(`Opening Opal`)
await open.openApp(app)