I've just found a way around this by using this connection string:
FullUri=file:memory.db?mode=memory&cache=shared
This creates an in-memory database that's shared amongst all connections with the same connection string, providing at least one connection is kept open. To the best of my knowledge the following config setting is still necessary:
<property name="connection.release_mode">on_close</property>