Fix view leak

Closes issue #2712.