Handle and scrub ending _controller gracefully in controller generator

Handle and scrub ending `_controller` gracefully in controller generator