properly shutdown app