You can also do it another way.
_foo ()
{
local _retval
declare -n output="$1" # $output is local (by default with declare in a functionfunc.)
## and points to $1
output="baz" && false
_retval=$?
echo ${_retval} # change echo to exit
}
Now call _foo this way:
$ _foo bar
1
$ echo "$bar"
baz
When you change echo to exit in the function definition, the exit will exit the script.