Fixed memory leak when closing storage

Notes and tags were not freed when switching storage or closing application.