Have you ever waited a while for a query to finish only to find out that it's not going to end in a reasonable time? Does your system consist of many shards?
If you answered 'yes' to both questions, you probably know that killing a stuck query on all shards can be a very frustrating task because MongoDB's killOp database method will kill a query only on a single shard.
However, using the following script will kill the query on all shards (When connected to admin database. Run at your own risk):
Explanation: This will kill all queries running for more than 20 minutes on all shards. You can, of course, filter by the original query parameters if you only want to kill your own query.