Fixed segmentation fault while pressing end button.