Oh that's quite awkward. That makes Vala the only language I have ever used that decides when the file can be closed instead of the programmer.You don't need to specify to close the file because it is automatically closed!
Consider:
Open a file for writing
Write a bash script to it.
Flush the file
chmod it
try to execute the new script from within your vala program
Error: File is busy!
I can code around this by putting the file writing in a sub-routine, the file is closed when the routine finishes and goes out of scope.
FileStream.close(fp) would be so much better.
Mobeus