Fixed a bug with the upload being cleaned up before the failed event is fired when an error occurs. This prevented the event from being fired to listeners and didn't allow the listeners to get information about the failure.