You are developing an application that subscribes to a single Pub/Sub topic and inserts corresponding rows into a database. The application runs on Linux using preemptible VMs to minimize costs. How should you design a shutdown script to ensure a graceful shutdown?