def cleanup():
    """Cleanup function to terminate all bot processes.

    Called during server shutdown.
    """
    for entry in bot_jobs.values():
        func = modal.FunctionCall.from_id(entry[0])
        if func:
            func.cancel()
Cleanup function to terminate all bot processes.

    Called during server shutdown.
    
examples/deployment/modal-example/server/app.py