Clear selection, context and rename for deleted files.

Fix for #9214.

cc @ingorichter