[ticket/317] Use correct block name in END statement

Fixes #317