Fix for exception thrown when cancelling generating source from code