added ESC key handler to exit the viewer