def shutdown(app):
    """
    Gracefully shutdown redis

    :param app: app instance to retrieve redis connection from
    """
    async def internal_shutdown():
        # Retrieve redis
        redis = app.state.redis

        # Close the connection and wait
        redis.close()
        await redis.wait_closed()

    return internal_shutdown