use a transaction and close the database, maybe this will help to avoid the timeout problem I see from time to time