fix cleanup routine

Made sure to release the camera in every error or end sequence