tests: Quit the mainloop from the main thread.