Close documents if open is canceled.

Implements a TODO. While I feel this change is pretty safe, I'm not quite sure
it has correct behavior in every circumstance. Still beats the TODO, though.