Use a more idiomatic syntax to capture the exit.