fix 5671, 5669

- Enable close command to close custom viewer,
- close image on project close.

fixes #5671 and #5669