Bowser hammers in levels 6-4, 7-4, 8-4

I got Bowser throwing hammers in the upper levels, although he still throws them after he is dead...... I couldn't figure out a clean way to make him stop, so I made Mario invisible after completing the castle levels, it's a total hack but works for now.