diff --git a/inc/Tree.hpp b/inc/Tree.hpp
index aad1653..6a713d8 100644
--- a/inc/Tree.hpp
+++ b/inc/Tree.hpp
@@ -28,6 +28,7 @@ public:
   ~Tree();
   void draw(Rectangle dest, float rotation);
   void newTree();
+  void deinit();
 
 private:
   int size = 0;
diff --git a/src/App.cpp b/src/App.cpp
index 13a016c..2f6699d 100644
--- a/src/App.cpp
+++ b/src/App.cpp
@@ -20,6 +20,7 @@ void App::init()
   destA = CalculateRect(center, rotation, screenWidth, screenWidth);
   destB = {destA.x, destA.y, (float)screenWidth, (float)screenWidth};
 }
+
 void App::update()
 {
   if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))
@@ -42,10 +43,18 @@ void App::update()
     destA = CalculateRect(center, rotation, screenWidth, screenWidth);
   }
 }
+
 void App::draw()
 {
   ClearBackground(RED);
   trees[pos].draw(destB, 0.0f);
   trees[1 - pos].draw(destA, rotation);
 }
-void App::deinit() {}
\ No newline at end of file
+
+void App::deinit()
+{
+  for (size_t i = 0; i < trees.size(); i++)
+  {
+    trees[i].deinit();
+  }
+}
\ No newline at end of file
diff --git a/src/Tree.cpp b/src/Tree.cpp
index f96904c..d47d952 100644
--- a/src/Tree.cpp
+++ b/src/Tree.cpp
@@ -17,7 +17,6 @@ Tree::Tree(int size)
 
 Tree::~Tree()
 {
-  UnloadRenderTexture(target);
 }
 
 void Tree::draw(Rectangle dest, float rotation)
@@ -38,6 +37,11 @@ void Tree::newTree()
   EndTextureMode();
 }
 
+void Tree::deinit()
+{
+  UnloadRenderTexture(target);
+}
+
 // Private
 
 Vector2 Tree::drawLine()
diff --git a/src/main.cpp b/src/main.cpp
index 4191300..2e107ac 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -15,17 +15,17 @@ int main(void)
   InitWindow(screenWidth, screenHeight, name);
 #endif
   SetTargetFPS(60);
+
+  App app(screenWidth, screenHeight);
+  app.init();
+  while (!WindowShouldClose())
   {
-    App app(screenWidth, screenHeight);
-    app.init();
-    while (!WindowShouldClose())
-    {
-      app.update();
-      BeginDrawing();
-      app.draw();
-      EndDrawing();
-    }
+    app.update();
+    BeginDrawing();
+    app.draw();
+    EndDrawing();
   }
+  app.deinit();
 
   CloseWindow();
   return 0;