Fix WriteFile flushing stream more than once

WriteFile creates an Action which disposes of the stream, this is then
sent to WriteFileCommon which invokes this action and attempts to flush
the stream a second time.  This can raise an ObjectDisposed Exception as
Flush will be called on a closed stream.
Merge pull request #734 from toolboc/universalapping

Fix WriteFile flushing stream more than once