Fixing a bug with cancelling timeouts