Most of the times you place any custom webpart in your page, you will get error page with the errors like “Error Occured”, “Unexpected Error Occured” etc.
In this case you can’t close the webpart directly because you cant open the page itself.
To close this webparts you must access the webparts maintenance page which is not accessible via a link right now. So just paste the ?contents=1 at the end of the url.
You will get the web parts maintainance page from where you can close the web part.