Handle SQL_QUIT event