Actually call Close() for shared region modules when the simulator is being shutdown.

Adds regression test for this case.