Avoid crash by invalidating timer before stopping run loop.