Bug fix: close onsets database in finally block