Bugfix for issue #655

Calling close without having calling render causes the ui object to
disappear, if defined.