Fixed wrong clean up of .end() call