Make sure to cleanup resources properly.