Fix issues when write destructs.
When the DataSetAppendWriter is destructed, it calls a close on the adios engine. If this happens after MPI_Finalize(), it will cause errors because adios is making MPI calls. This came up in a simple code where everything happened inside of main(). The writer was in the main function's scope. This also fixes an issue in the test-write where it was not doing step selection correctly.