Fix cancelling network request from within main thread