use a lambda to figure out when to stop proxy