Exit on close.
Fixed the invalid index error
A bit graphical change