How to delete Views under Jenkins without affecting existing jobs
For deleting a view (and not touching any jobs therein) use
def view = Jenkins.instance.getView("MyView")
Jenkins.instance.deleteView( view )
Your code deletes the jobs in the view (but not the view itself), so be careful with that : )
go to view --> edit view --> unchecked all jobs on that view --> Save --> Delete View