fixed minor bug on viewer close.