added quit button handler and replay function