Handle SQL_QUIT event

This way when you close the window the process will finish, instead of holding the terminal/console or stuck in the background.