makes program exit when closed