Thanks, it seems to work. I think my main problem was I was trying to use it in my class (QMainWindow):

I tried
qApp->quit();

that didn't do anything.

I tried
close(); (because QMainWindow has a close function)
but apparently, your singleShot timer works awesome, thanks I had forgotten about that.