Add index cleanup if index creation fails

Fixes #2590