Can a query write to the binary log BEFORE it has finished executing?
well, it doesn't explain why the database locked up but it does answer part of my question:


  When a transaction is sent to a MySQL server running with binary
  logging enabled, the transaction is executed normally, and just prior
  to completing the transaction the server records the change serially
  in the binary log. Once this is done, it tells the storage engine that
  the transaction is ready to be committed.


https://www.packtpub.com/books/content/setting-mysql-replication-high-availability



Although, I've now just read the following:

The SQL statements are not


  The SQL statements are not
  written into the binary log until the transaction commits,


which is from the 'Understanding MySQL Internals' book.