Added: - try-finally Block: This makes sure the camera.release() is called no matter how the while loops end. - Resource Cleanup: The finally block takes care of cleaning up resources to keep the application stable.