MySQL handles an error situation by rolling back the transaction itself.
Rolling back can be a slow operation that may occur implicitly without the user having explicitly asked for it (for example, when an error occurs).
The MySQL documentation covers your "what if case"
If a session that has autocommit disabled ends without explicitly committing the final transaction, MySQL rolls back that transaction.
Further:
Both commit and rollback release all InnoDB locks that were set during the current transaction.
Edit: I set up a test for your proposed situation. Using an innoDB table with MySQL 5.
$db = new DB();
$db->beginTransaction();
$db->exec("INSERT INTO `table` (`val`) VALUES('commit?')");
sleep(30);
$db->commit();
This works as I've described below in the comments. If allowed to complete, the transaction is committed to the table after 30 seconds.
If I kill the script before allowing it to complete, the transactions is rolled back and the table is left in a clean state - as expected.