First of all you need to check if it really stops the query or just does not wait for the query. you can do it If you I know the database type (Oracle, MySQL, ...) I can let you know the proper command to check this.
If it really kills the query, Probably it gets and stores the Session ID when running the query and submits the proper kill command (you have already selected the database type).