Fix extract dialog

When using the dialog is nothing was selected, the temp file wouldn't be deleted and stashed changes would not be restored. 

Lowered the lifespan of the temp file by immediately reading from it.
Restore the open changes the script errors out.