Image viewer exit function