Changed order of Script save. This avoids a race condition where Scripts that die very quickly tries to delete themselves before having had time to save first. Resolves #597.